[Solved] $lang in user defined tag

This is a FORK of the CMS Made Simple project and is not oficially supported in any way by the CMS Made Simple development team.
Locked
Dutch_guy
Forum Members
Forum Members
Posts: 64
Joined: Wed Apr 23, 2008 11:19 am

[Solved] $lang in user defined tag

Post 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.
Last edited by Dutch_guy on Wed Jun 16, 2010 11:44 am, edited 1 time in total.
Peciura

Re: $lang in user defined tag

Post 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*/
Dutch_guy
Forum Members
Forum Members
Posts: 64
Joined: Wed Apr 23, 2008 11:19 am

Re: $lang in user defined tag

Post by Dutch_guy »

It works great ! Thanks alot !
Peciura

Re: $lang in user defined tag

Post by Peciura »

Add '[Solved]' to the subject of your first post.
Locked

Return to “[locked] CMSMS MLE fork”