Page 1 of 1

Visibility of global smarty variables

Posted: Wed Jul 20, 2016 11:24 am
by virgo
I'm trying to get our website using MleCMS to work with CMSMS 2.0.
Now I got it basically working, but there is on problem.

At the beginning of site template I have {MleCMS action="init"}, which sets global variables lang_parent, lang_locale, lang_dir with $smarty->assignGlobal

But {$lang_locale} returns empty string until after html head tag (when it starts to show correct values).

For debugging I added (inside html comments)

lang_locale="{$lang_locale}"
{get_template_vars}

into main template after module init... $lang_locale is empty, but get_template_vars shows it having value.

I'm using CMSMS 2.1.4

Re: Visibility of global smarty variables

Posted: Thu Jul 21, 2016 7:29 am
by virgo
And I solved problem currently with UDT containing:

$smarty->assign('lang_dir', $smarty->get_template_vars('lang_dir'));
$smarty->assign('lang_locale', $smarty->get_template_vars('lang_locale'));
$smarty->assign('lang_parent', $smarty->get_template_vars('lang_parent'));

Re: Visibility of global smarty variables

Posted: Fri Jul 22, 2016 5:50 pm
by Jeff
It might be an issue with smarty caching of the variable. I am not sure how to fix it.

Re: Visibility of global smarty variables

Posted: Fri Jul 22, 2016 6:06 pm
by Rolf

Code: Select all

{MleCMS action="init"}
{$lang_dir=$lang_dir scope=global}
{$lang_locale=$lang_locale scope=global}
{$lang_parent=$lang_parent scope=global}
http://www.cmscanbesimple.org/blog/smar ... e-examples

Re: Visibility of global smarty variables

Posted: Sat Jul 23, 2016 4:43 am
by virgo
Rolf wrote:

Code: Select all

{MleCMS action="init"}
{$lang_dir=$lang_dir scope=global}
{$lang_locale=$lang_locale scope=global}
{$lang_parent=$lang_parent scope=global}
http://www.cmscanbesimple.org/blog/smar ... e-examples
Yeah, that's basically what my solution does. But strange thing is, that I modified MleCMS to set those variables with AssignGlobal. So they are in global scope. Before that change those variables were not visible at any part of template. After that they become visible after "head" tag.

Re: Visibility of global smarty variables

Posted: Sat Jul 23, 2016 4:46 am
by virgo
Jeff wrote:It might be an issue with smarty caching of the variable. I am not sure how to fix it.
Probably. But since I was able to work around the issue, that's no longer major issue for me. But I should probably publish somewhere the changes I made to MleCMS to get it working.

Re: Visibility of global smarty variables

Posted: Sat Jul 23, 2016 6:09 am
by Rolf
Post a bug report in the Forge