setting language variable

General project discussion. NOT for help questions.
Post Reply
designer
New Member
New Member
Posts: 8
Joined: Fri Jun 11, 2010 1:13 pm

setting language variable

Post by designer »

Hi' there

A little lost here so hoping one of you guys could help out with this probably simple problem.

I need to do a check on the language variable $lang in the shopmadesimple template.
On the first page of my site using I try to set this variable using {assign var="lang" value="us_uk"} but once I read it in the shopmadesimple module it got a different value.

Any idea how to make my assigned value stick? or are there any way to do this by maybe creating some other global variable that I can access from all modules?
designer
New Member
New Member
Posts: 8
Joined: Fri Jun 11, 2010 1:13 pm

Re: setting language variable

Post by designer »

Nobody knows? at least how to setup a global varible that can be accessed in all modules?
I have tried {assign var="lang" value="en_UK"} but it only seems to keep the value on the current page, I have tried make a UTD
and setting them there with
"
global $gCms;
global $smarty;
$smarty->assign('lang',"en_UK");
$gCms->current_language ="en_UK";
"
Still only sticks for that one page, as soon as I goto a new page the changes seems forgotten.
Last edited by designer on Thu Sep 16, 2010 9:42 am, edited 1 time in total.
designer
New Member
New Member
Posts: 8
Joined: Fri Jun 11, 2010 1:13 pm

Re: setting language variable

Post by designer »

None here knows how to keep a variable global across the templates?
vilkis

Re: setting language variable

Post by vilkis »

What is version of CMSMS?

try to add the following line to UDT:

Code: Select all

$gCms->config['locale'] = 'en_UK';
and call your UDT at the top of page template.

vilkis
designer
New Member
New Member
Posts: 8
Joined: Fri Jun 11, 2010 1:13 pm

Re: setting language variable

Post by designer »

Thanks for your reply Vilkis, but it didn't seem to change anything or me using it incorrectly.

I had even tried adding varibale in the gcms class and that didn't work either.

here's the full UTD

global $gCms;
global $smarty;

$gCms->config['locale'] = 'en_UK';

if( isset($params['langparms']) )
{
$gCms->current_language=$params['langparms'];
$gCms->mylang=$params['langparms'];
$smarty->assign('lang',$params['langparms']);
$lang=$params['langparms'];
}
else{
echo ("1".$gCms->current_language."");
echo ("2".$gCms->mylang."");
}


It works fine on the same page, even the {$lang} is right there, but as soon as I call it on some other page which isn't setting the langsparms it seems to have forgotten my values I set on the former page.

Would have expect the Global to make the variable global.
vilkis

Re: setting language variable

Post by vilkis »

it is normal, or I do not understand what are you trying to do.
vilkis
designer
New Member
New Member
Posts: 8
Joined: Fri Jun 11, 2010 1:13 pm

Re: setting language variable

Post by designer »

Well basicly I just want set a variable on the entrance page, and then read the value of that variable in the shopmadesimple template. Depending on it's value show either one product attribute or another. Would have thought that was a really simple thing to do but doesn't seem so.
vilkis

Re: setting language variable

Post by vilkis »

Is your site multilangual? If so, how do you do it: use different templates for each language?
Does visitor select a language he prefer?

I know that it is doable but I do not understand how things are organized in your site. Live site would help...
vilkis
Peciura

Re: setting language variable

Post by Peciura »

designer: global is not static variable so it can be cleared if not used. You could save locale to SESSION variable (CGSimpleSmarty module),or to COOKIE.

Since you are using variable {$lang} i assume you are using CMSms-mle-fork (not regular CMSms). In this case there is a board dedicated for it , {$lang} is set every time page is accessed. Language is chosen in following order:
  1. $_POST['hl']
  2. $_GET['hl']
  3. $_COOKIE['mle']
  4. $_SERVER['HTTP_ACCEPT_LANGUAGE'] //visitor preferred language
  5. $_SERVER['HTTP_USER_AGENT']  //visitor preferred language
  6. default language from "MLE languages"
After language is chosen $_COOKIE is set for 5 hours, buts still $_GET is preferred.
Last edited by Peciura on Fri Sep 24, 2010 12:34 pm, edited 1 time in total.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm

Re: setting language variable

Post by RonnyK »

I wouldnt expect this to be a MLE question, as this is a CORE-board ;)

If this is a question concerning MLE, please move to the appropiate board.

Ronny
designer
New Member
New Member
Posts: 8
Joined: Fri Jun 11, 2010 1:13 pm

Re: setting language variable

Post by designer »

Don't use the MLE seemed to recall reading somewhere that it wasn't quite up to date with the newest version of cmsmadesimple. And seemed a bit to much just to set one simple variable which seemed to be there anyway.

Got it working using the CGSimpleSmarty as Peciura suggested, with that I was able to save a variable value across the various templates and plugins.

So thank you for your help guys.
Post Reply

Return to “General Discussion”