Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

How to get clickable language flags instead of dropdown Rate Topic   - - - - -

 
  • Flow
  • Super Duper and Amazingly Sexy Senior
  • Members
  • Join Date: 13-Oct 10
  • 2271 posts

Posted 14 October 2011 - 12:59 PM #1

I guess the title says it all. I only have 2 languages and would like the flags to always show and be clickable, instead of having the dropdown.

Shouldn't be to hard I guess to figure out but I hope someone already knows how to do it and can tell me..

Thanks!

When life hands you lemons, bring on the Tequila baby!


 
  • Flow
  • Super Duper and Amazingly Sexy Senior
  • Members
  • Join Date: 13-Oct 10
  • 2271 posts

Posted 26 October 2011 - 07:32 AM #2

No one?

When life hands you lemons, bring on the Tequila baby!


 
  • LouiePoll
  • Newbie
  • Members
  • Join Date: 19-Nov 11
  • 1 posts

Posted 19 November 2011 - 02:10 PM #3

I actually have the same problem. I hope there's someone here who can help....

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11266 posts

Posted 19 November 2011 - 05:13 PM #4

Change this section in top.tpl to use anchor tags rather than calling the selector include. You should be able to figure out which images to use based on your languages.
<div class="select-wrap">{include file="common_templates/select_object.tpl" style="graphic" suffix="currency" link_tpl=$config.current_url|fn_link_attach:"currency=" items=$currencies selected_id=$secondary_currency display_icons=false key_name="description"}</div>

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Flow
  • Super Duper and Amazingly Sexy Senior
  • Members
  • Join Date: 13-Oct 10
  • 2271 posts

Posted 19 November 2011 - 05:46 PM #5

Thanks!

When life hands you lemons, bring on the Tequila baby!


 
  • Flow
  • Super Duper and Amazingly Sexy Senior
  • Members
  • Join Date: 13-Oct 10
  • 2271 posts

Posted 30 November 2011 - 10:06 AM #6

Here we go (as you can see this is for English and German)

Where you want your flags to appear put:

<div class="language_links">
{if $languages|sizeof > 1}
				{assign var="link_tpl" value=$config.current_url|fn_link_attach:"sl="}
				<div class="languages">
				{foreach from=$languages item=item key=id}
					<a style="margin: 5px;" rel="nofollow" name="{$id}" href="{"`$link_tpl``$id`"|fn_url}">{if $id == "EN"}<img src="{$images_dir}/flags/en.png" border="0" alt="English" title="English"/> {else} <img src="{$images_dir}/flags/de.png" border="0" alt="Deutsch" title="Deutsch"/>{/if}</a>
				{/foreach}
				</div>
			{/if}

Of course edit the css accordingly

When life hands you lemons, bring on the Tequila baby!


 
  • rfdsign
  • Newbie
  • Members
  • Join Date: 14-Dec 11
  • 7 posts

Posted 14 December 2011 - 04:17 PM #7

Hi flow, very helpfull, i wanted to add it, but i have 3 languages installed, this is what i did:

<div class="language_links">
{if $languages|sizeof > 1}
								{assign var="link_tpl" value=$config.current_url|fn_link_attach:"sl="}
								<div class="languages">
								{foreach from=$languages item=item key=id}
										<a style="margin: 5px;" rel="nofollow" name="{$id}" href="{"`$link_tpl``$id`"|fn_url}">{if $id == "EN"}<img src="{$images_dir}/flags/en.png" border="0" alt="English" title="English"/> {else} <img src="{$images_dir}/flags/nl.png" border="0" alt="Nederlands" title="Nederlands"/> {else} <img src="{$images_dir}/flags/es.png" border="0" alt="Espanol" title="Espanol"/>{/if}</a>

								{/foreach}
								</div>
						{/if}

But i get a smarty error with an unexpected {else}:

Fatal error: Smarty error: [in top.tpl line 73]: syntax error: unexpected {else} (Smarty_Compiler.class.php, line 477) in /home/amezary/public_html/lib/templater/Smarty.class.php on line 1095

I guess copying another language doesn't work in this mod,

Is there a Fix?

Thanks in advance!

 
  • StellarBytes
  • Senior Member
  • Members
  • Join Date: 08-Aug 11
  • 1807 posts

Posted 14 December 2011 - 04:55 PM #8

You're using an 'if else else' statement.

You should use an if, elseif and else statement, see the php documentation example below:

<?php
if ($a > $<img src='http://forum.cs-cart.com/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' /> {
    echo "a is bigger than b";
} elseif ($a == $<img src='http://forum.cs-cart.com/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' /> {
    echo "a is equal to b";
} else {
    echo "a is smaller than b";
}
?>

Hire StellarBytes for CS-Cart Design & Development Services

 
  • rfdsign
  • Newbie
  • Members
  • Join Date: 14-Dec 11
  • 7 posts

Posted 14 December 2011 - 05:06 PM #9

Hi Stellar, what would be the correct code then? i tried elseif but i get the same error:

Could you paste the correct code please, i am not a programmer

Thanks in advance!

 
  • Flow
  • Super Duper and Amazingly Sexy Senior
  • Members
  • Join Date: 13-Oct 10
  • 2271 posts

Posted 14 December 2011 - 05:06 PM #10

Hmm, I guess it has something to do with the {else} command being used twice. I'm sure a coder can solve this very easily... but I'm not a coder :)

Anyone?

When life hands you lemons, bring on the Tequila baby!


 
  • rfdsign
  • Newbie
  • Members
  • Join Date: 14-Dec 11
  • 7 posts

Posted 17 December 2011 - 11:10 PM #11

I am no coder either, Gotta finish this project :?

I tried the suggested: if / elseif / else, but doesnt work......

Can anyone paste the correct code in the one provided?

Thanks in advance

<div class="language_links">
{if $languages|sizeof > 1}
															    {assign var="link_tpl" value=$config.current_url|fn_link_attach:"sl="}
															    <div class="languages">
															    {foreach from=$languages item=item key=id}
																			    <a style="margin: 5px;" rel="nofollow" name="{$id}" href="{"`$link_tpl``$id`"|fn_url}">{if $id == "EN"}<img src="{$images_dir}/flags/en.png" border="0" alt="English" title="English"/> {elseif} <img src="{$images_dir}/flags/nl.png" border="0" alt="Nederlands" title="Nederlands"/> {else} <img src="{$images_dir}/flags/es.png" border="0" alt="Espanol" title="Espanol"/>{/if}</a>
															    {/foreach}
															    </div>
											    {/if}


 
  • StellarBytes
  • Senior Member
  • Members
  • Join Date: 08-Aug 11
  • 1807 posts

Posted 18 December 2011 - 09:50 PM #12

Not tested, but should work like this:

<div class="language_links">
{if $languages|sizeof > 1}
															    {assign var="link_tpl" value=$config.current_url|fn_link_attach:"sl="}
															    <div class="languages">
															    {foreach from=$languages item=item key=id}
																			    <a style="margin: 5px;" rel="nofollow" name="{$id}" href="{"`$link_tpl``$id`"|fn_url}">{if $id == "EN"}<img src="{$images_dir}/flags/en.png" border="0" alt="English" title="English"/> {elseif} <img src="{$images_dir}/flags/nl.png" border="0" alt="Nederlands" title="Nederlands"/> {else} <img src="{$images_dir}/flags/es.png" border="0" alt="Espanol" title="Espanol"/>{/if}</a>

															    {/foreach}
															    </div>
											    {/if}

Hire StellarBytes for CS-Cart Design & Development Services

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11266 posts

Posted 18 December 2011 - 09:58 PM #13

Maybe I'm missing something, but why would you want to encode all the various languages in the html with ifelse's versus letting the system do it for you? Seems to overly complicate things and is not dynamic at all....

	{if $languages|sizeof > 1}
		<div class="language_links float-left">
			{assign var="link_tpl" value=$config.current_url|fn_link_attach:"sl="}
			<div class="languages">
				{foreach from=$languages item=item key=id}
					{assign var="lower_lang_code" value=$item.lang_code|strtolower}
						<a rel="nofollow" name="{$id}" href="{$link_tpl|cat:$id}">
							<img src="{$images_dir}/flags/{$lower_lang_code}.png"
								border="0"
								alt="{$item.name}"
								title="{$item.name}"
							/>
						</a>
				{/foreach}
			</div>
		</div>
	{/if}

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • rfdsign
  • Newbie
  • Members
  • Join Date: 14-Dec 11
  • 7 posts

Posted 19 December 2011 - 05:18 AM #14

Thank you very much!

Works like a charm!

All the best
Francois

 
  • senove
  • Junior Member
  • Members
  • Join Date: 03-Mar 07
  • 40 posts

Posted 19 October 2018 - 10:52 AM #15

For the new versions, 4.x.x, how to modify?

 

Thanks1



 
  • galtinbaeva
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 06-Dec 13
  • 3312 posts

Posted 19 October 2018 - 01:56 PM #16

For the new versions, 4.x.x, how to modify?

 

Thanks1

 

Hello!

 

Please go to the Languages block settings on the Design->Layouts page and change Minimal number if items to be placed in a dropdown list value. For example, if you have 2 languages, specify 3 in the setting.


Simtech Development | sales@simtechdev.com | www.simtechdev.com
CERTIFIED CS-CART PARTNER | LICENSES | DEVELOPMENT | ADD-ONS | DESIGN | UPGRADE

Google Analytics Enhanced Ecommerce - get advanced ecommerce analytics


 
  • senove
  • Junior Member
  • Members
  • Join Date: 03-Mar 07
  • 40 posts

Posted 21 October 2018 - 08:44 AM #17

Great! Thanks