Jump to content

[SOLVED] adapting blocklanguages - how to add custom links


Recommended Posts

Hi, I have PS 1.3.6, how I can adapting blocklanguages for do it this:

 

- when I click on a language flag I would open a custom URL (external)

 

this is the code of blocklanguages

<!-- Block languages module -->
<div id="languages_block_top">
	<label>{l s='Languages' mod='blocklanguages'}:</label>
	<ul id="first-languages">
		{foreach from=$languages key=k item=language name="languages"}
			<li {if $language.iso_code == $lang_iso}class="selected_language"{/if}>
				{if $language.iso_code != $lang_iso}<a href="{$link->getLanguageLink($language.id_lang, $language.name)}" title="{$language.name}">{/if}
					<img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
				{if $language.iso_code != $lang_iso}</a>{/if}
			</li>
		{/foreach}
	</ul>
</div>
<script type="text/javascript">
	$('ul#first-languages li:not(.selected_language)').css('opacity', 0.55);
	$('ul#first-languages li:not(.selected_language)').hover(function(){ldelim}
		$(this).css('opacity', 1);
	{rdelim}, function(){ldelim}
		$(this).css('opacity', 0.55);
	{rdelim});
</script>
<!-- /Block languages module -->

thanks

Link to comment
Share on other sites

hello

 

make sure that your theme does not override this file

if you've got themes/YOUR_THEME/modules/blocklanguages/blocklaguages.tpl file you have to edit this one.

 

in addition to this, turn on force compile under adv. parameters > performance tab (and also turn cache off)

 

moreover, i show you only example how to achieve what you expected, can you show how your code looks like ?

Link to comment
Share on other sites

<!-- Block languages module -->
<div id="languages_block_top">
    <label>{l s='Languages' mod='blocklanguages'}:</label>
    <ul id="first-languages">
        {foreach from=$languages key=k item=language name="languages"}
            
<li {if $language.iso_code == $lang_iso}class="selected_language"{/if}>
                {if $language.iso_code != $lang_iso}<a href="{$link->getLanguageLink($language.id_lang, $language.name)}" title="{$language.name}">{/if}
                    
<img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
                {if $language.iso_code != $lang_iso}</a>{/if}

{if $language.iso_code == "en"}<a href="HTTP://MYLINK.COM" title="{$language.name}">
            </li>
        {/foreach}
    
</ul>
</div>
<script type="text/javascript">
    $('ul#first-languages li:not(.selected_language)').css('opacity', 0.55);
    $('ul#first-languages li:not(.selected_language)').hover(function(){ldelim}
        $(this).css('opacity', 1);
    {rdelim}, function(){ldelim}
        $(this).css('opacity', 0.55);
    {rdelim});
</script>
<!-- /Block languages module -->

Edited by casitto (see edit history)
Link to comment
Share on other sites

I try also this:

 

 

 

<!-- Block languages module -->
<div id="languages_block_top">
    <label>{l s='Languages' mod='blocklanguages'}:</label>
    <ul id="first-languages">
        {foreach from=$languages key=k item=language name="languages"}
            
<li {if $language.iso_code == $lang_iso}class="selected_language"{/if}>
             {if $language.iso_code == "en"}<a href="HTTP://MYLINK.COM" title="{$language.name}">
                    <img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
                {if $language.iso_code != $lang_iso}</a>{/if}
            
</li>
        {/foreach}
    
</ul>
</div>
<script type="text/javascript">
    $('ul#first-languages li:not(.selected_language)').css('opacity', 0.55);
    $('ul#first-languages li:not(.selected_language)').hover(function(){ldelim}
        $(this).css('opacity', 1);
    {rdelim}, function(){ldelim}
        $(this).css('opacity', 0.55);
    {rdelim});
</script>
<!-- /Block languages module -->


I'm sorry but code don't work in edit option...

Link to comment
Share on other sites

your code doesn't work, use this one:

<!-- Block languages module -->
{if count($languages) > 1}
<div id="languages_block_top">
	<div id="countries">
	{* @todo fix display current languages, removing the first foreach loop *}
{foreach from=$languages key=k item=language name="languages"}
	{if $language.iso_code == $lang_iso}
		<p class="selected_language">
			<img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
		</p>
	{/if}
{/foreach}
		<ul id="first-languages" class="countries_ul">
		{foreach from=$languages key=k item=language name="languages"}
			<li {if $language.iso_code == $lang_iso}class="selected_language"{/if}>
			{if $language.iso_code == "en"}
                <a href="HTTP://MYLINK.COM" title="{$language.name}">

don't forget to define urls to other languages, for now - you've got here only english language: {if $language.iso_code == "en"}

Link to comment
Share on other sites

ohh you've got right, something bad went here :|


<!-- Block languages module -->
{if count($languages) > 1}
<div id="languages_block_top">
	<div id="countries">
	{* @todo fix display current languages, removing the first foreach loop *}
{foreach from=$languages key=k item=language name="languages"}
	{if $language.iso_code == $lang_iso}
		<p class="selected_language">
			<img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
		</p>
	{/if}
{/foreach}
		<ul id="first-languages" class="countries_ul">
		{foreach from=$languages key=k item=language name="languages"}
			<li {if $language.iso_code == $lang_iso}class="selected_language"{/if}>
		      {if $language.iso_code == "en"}
              <a href="HTTP://MYLINK.COM" title="{$language.name}">
<img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
		      {/if}
			</li>
		{/foreach}
		</ul>
	</div>
</div>

<script type="text/javascript">
$(document).ready(function () {
	$("#countries").mouseover(function(){
		$(this).addClass("countries_hover");
		$(".countries_ul").addClass("countries_ul_hover");
	});
	$("#countries").mouseout(function(){
		$(this).removeClass("countries_hover");
		$(".countries_ul").removeClass("countries_ul_hover");
	});

});
</script>
{/if}
<!-- /Block languages module -->

Link to comment
Share on other sites

 

 

Hi, I try to put your entire code but nothing change

it mean that your store displays cached file (clear shop cache) or that you changed wrong file - does file themes/YOUR_THEME/modules/blocklanguages/blocklanguages.tpl exist?

Link to comment
Share on other sites

ok im back :)

 

here is the code for blocklanguages.tpl for 1.3.6 version with modifications:

<!-- Block languages module -->
<div id="languages_block_top">
	<ul id="first-languages">
		{foreach from=$languages key=k item=language name="languages"}
			<li {if $language.iso_code == $lang_iso}class="selected_language"{/if}>
                {if $language.iso_code == "en"}
                    <a href="HTTP://united_kingdom.COM" title="{$language.name}">
                    <img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
                    </a>
                {/if}
                {if $language.iso_code == "es"}
                    <a href="HTTP://spain.COM" title="{$language.name}">
                    <img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
                    </a>
                {/if}
                {if $language.iso_code == "fr"}
                    <a href="HTTP://france.COM" title="{$language.name}">
                    <img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
                    </a>
                {/if}
			</li>
		{/foreach}
	</ul>
</div>
<script type="text/javascript">
	$('ul#first-languages li:not(.selected_language)').css('opacity', 0.3);
	$('ul#first-languages li:not(.selected_language)').hover(function(){ldelim}
		$(this).css('opacity', 1);
	{rdelim}, function(){ldelim}
		$(this).css('opacity', 0.3);
	{rdelim});
</script>
<!-- /Block languages module -->

i added 3 if conditions to check english, spain, and france language versions

Link to comment
Share on other sites

<!-- Block languages module -->
<div id="languages_block_top">
	<ul id="first-languages">
		{foreach from=$languages key=k item=language name="languages"}
			<li {if $language.iso_code == $lang_iso}class="selected_language"{/if}>
                {if $language.iso_code == "jp"}
                    <a href="HTTP://japanese.COM" title="{$language.name}">
                    <img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
                    </a>
                {/if}
                {if $language.iso_code == "it"}
                    <a href="HTTP://italian.COM" title="{$language.name}">
                     <img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
                    </a>
                {/if}
                
			</li>
		{/foreach}
	</ul>
</div>
<script type="text/javascript">
	$('ul#first-languages li:not(.selected_language)').css('opacity', 0.3);
	$('ul#first-languages li:not(.selected_language)').hover(function(){ldelim}
		$(this).css('opacity', 1);
	{rdelim}, function(){ldelim}
		$(this).css('opacity', 0.3);
	{rdelim});
</script>
<!-- /Block languages module -->

of course you have to define own links to websites, instead of HTTP://japanese.COM and HTTP://italian.COM just use own correct urls

Link to comment
Share on other sites

with this code:

<!-- Block languages module -->
<div id="languages_block_top">
    <ul id="first-languages">
        {foreach from=$languages key=k item=language name="languages"}
            <li {if $language.iso_code == $lang_iso}class="selected_language"{/if}>
                {if $language.iso_code == "jp"}
                    <a href="HTTP://mysite.jp" title="{$language.name}">
                    <img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
                    </a>
                {/if}
                {if $language.iso_code == "it"}
                    <a href="HTTP://www.mysite.com" title="{$language.name}">

                     <img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
                    </a>
                {/if}
                
            </li>
        {/foreach}
    </ul>
</div>
<script type="text/javascript">
    $('ul#first-languages li:not(.selected_language)').css('opacity', 0.3);
    $('ul#first-languages li:not(.selected_language)').hover(function(){ldelim}
        $(this).css('opacity', 1);
    {rdelim}, function(){ldelim}
        $(this).css('opacity', 0.3);
    {rdelim});
</script>
<!-- /Block languages module -->

 

 

 

the japanese flag disappears, the italian flag is ok

Edited by casitto (see edit history)
Link to comment
Share on other sites

ok, iso code for japan version is ja:

 

               {if $language.iso_code == "ja"}
                    <a href="HTTP://mysite.jp" title="{$language.name}">
                    <img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
                    </a>
                {/if}

 

have you cleared cache once again (after changes) ?

Link to comment
Share on other sites

I mean "ja"

 

 

this is the code I use now, the japanese flag disappear

 

 

<!-- Block languages module -->
<div id="languages_block_top">
    <ul id="first-languages">
        {foreach from=$languages key=k item=language name="languages"}
            <li {if $language.iso_code == $lang_iso}class="selected_language"{/if}>
                {if $language.iso_code == "ja"}
                    <a href="HTTP://mysite.jp" title="{$language.name}">
                    <img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
                    </a>
                {/if}
                {if $language.iso_code == "it"}
                    <a href="HTTP://www.mysite.com" title="{$language.name}">

                     <img src="{$img_lang_dir}{$language.id_lang}.jpg" alt="{$language.iso_code}" width="16" height="11" />
                    </a>
                {/if}
                
            </li>
        {/foreach}
    </ul>
</div>
<script type="text/javascript">
    $('ul#first-languages li:not(.selected_language)').css('opacity', 0.3);
    $('ul#first-languages li:not(.selected_language)').hover(function(){ldelim}
        $(this).css('opacity', 1);
    {rdelim}, function(){ldelim}
        $(this).css('opacity', 0.3);
    {rdelim});
</script>
<!-- /Block languages module -->

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...