Visibility of global smarty variables

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
virgo
Forum Members
Forum Members
Posts: 27
Joined: Thu May 29, 2008 10:00 am

Visibility of global smarty variables

Post 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
virgo
Forum Members
Forum Members
Posts: 27
Joined: Thu May 29, 2008 10:00 am

Re: Visibility of global smarty variables

Post 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'));
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm
Location: MI

Re: Visibility of global smarty variables

Post by Jeff »

It might be an issue with smarty caching of the variable. I am not sure how to fix it.
User avatar
Rolf
Dev Team Member
Dev Team Member
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Visibility of global smarty variables

Post 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
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
virgo
Forum Members
Forum Members
Posts: 27
Joined: Thu May 29, 2008 10:00 am

Re: Visibility of global smarty variables

Post 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.
virgo
Forum Members
Forum Members
Posts: 27
Joined: Thu May 29, 2008 10:00 am

Re: Visibility of global smarty variables

Post 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.
User avatar
Rolf
Dev Team Member
Dev Team Member
Posts: 7825
Joined: Wed Apr 23, 2008 7:53 am
Location: The Netherlands
Contact:

Re: Visibility of global smarty variables

Post by Rolf »

Post a bug report in the Forge
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Image
Post Reply

Return to “The Lounge”