Page 1 of 1

[Solved] $lang in user defined tag

Posted: Tue Jun 15, 2010 11:13 pm
by Dutch_guy
Hi,

I have the following user defined tag:

Code: Select all

if ($_GET['Error'] == 'Username or password incorrect.'){
  if ($lang == 'nl_NL'){    
      echo '<__script__ language="JavaScript">alert ("Inloggen mislukt, probeer opnieuw a.u.b.")</__script>';  
  }
}
How do I check for the current chosen language ? Normally with $lang, but that does not work in a user defined tag.

Also I cannot get the value from the url, because on the homepage it doesn't show the language in the url.

Re: $lang in user defined tag

Posted: Wed Jun 16, 2010 6:11 am
by Peciura
The easiest way is to pass $lang as parameter
{my_tag   lang=$lang} {*looks familiar, init ?*}
And use it like in UDT

Code: Select all

$lang = $params['lang'];
Another way - not so user friendly - to access smarty template variables directly
global $gCms;
$smarty =& $gCms->GetSmarty();
$lang = $smarty->get_template_vars('lang'); /* you can get any valid template variable*/

Re: $lang in user defined tag

Posted: Wed Jun 16, 2010 7:24 am
by Dutch_guy
It works great ! Thanks alot !

Re: $lang in user defined tag

Posted: Wed Jun 16, 2010 11:24 am
by Peciura
Add '[Solved]' to the subject of your first post.