Loading...
 

Features / Usability


Language variable for a condition in a Smarty Template

posts: 7877 Israel

Hello,

In a Smarty template I use with a plugin list, I need conditions depending on the language of the page.

Looking in the debug console of Tiki, I have a variable $frontendLang that equal the language abbreviation for the current page.

sprint $frontendLang
frontendLang = fr

In my Smarty template I set then:

{if $frontendLang eq 'fr'}En francais{/if}


But that the condition is not working (text is always displayed).
What am I missing ?


Note this is just a sample my code should be more like this in the end;
{CODE()}
{if $frontendLang eq 'fr'}

...french content

{elseif $frontendLang eq 'he'}

...hebrew content

{else}

...english content

{/if}

posts: 2193
I think the correct variable is $lang or $language. Try to put {$frontendLang} before the if to debug.

posts: 7877 Israel

I thought so...

I call the template using:

{LIST()}
   {output tplwiki="videoTutorials_tpl"}
{LIST}


In the wiki page (the template) I have:
1: {$frontendLang}
2 : {$language}
3 : {$languages}
4 : {$lang}
All return an empty value.



If I use the Tiki debugger I have for the same variable:
$frontendLang = en
$language = not found
$languages = array of all languages in use
$lang = en

May be something related to the way I’m including the template in the page ?


Why Register?

Register at tiki.org and you'll be able to use the account at any *.tiki.org site, thanks to the InterTiki feature. A valid email address is required to receive site notifications and occasional newsletters. You can opt out of these items at any time.

Newest Forum Posts