Page 1 of 1

[Solved] scope=global

Posted: Mon Aug 24, 2015 8:23 pm
by jce76350
Hi,

last rev 10109 Working on a multilingual web site FR, En, Es, De, with CGSimpleSmarty2.0

I use in the template at the top

Code: Select all

{process_pagedata} 
{assign var='rootlang' cgsimple::get_root_alias() scope=global}
{global_content name="languagestrings_`$rootlang`"}
With some string translation on my template
But Have a lot of errors message on my translation (languagestrings)

To have no error message
I comment at the top atfer {process_pagedata}
{*assign var='rootlang' cgsimple::get_root_alias() scope=global*}
{*global_content name="languagestrings_`$rootlang`"*}
I must write after </__body>
{assign var='rootlang' cgsimple::get_root_alias()}
{global_content name="languagestrings_`$rootlang`"}
and write after <head>
{assign var='rootlang' cgsimple::get_root_alias()}
{global_content name="languagestrings_`$rootlang`"}

Is there a problem now (Smarty 3.1.16) with scope=global ?

Re: scope=global

Posted: Tue Aug 25, 2015 3:33 pm
by calguy1000
First, your syntax is incorrect.

{assign var='rootlang' value=cgsimple::get_root_alias() scope=global} is the correct syntax.

Now. Given that there is a bug in CGSimpleSmarty for 2.0 (fixed in svn, thank you for the report). I tested this with other variable names at the top of my page template and it worked exactly as expected.

i.e: {assign var='test1' value='foo1' scope=global} or {$test2='foo2' scope=global}

note: that {assign var='test3' value='foo3'} (which does NOT have the global scope argument) also worked as expected. When I tried to reference the {$test3} variable in my page content the variable was not set and I got PHP notices.

Re: scope=global

Posted: Tue Aug 25, 2015 5:54 pm
by jce76350
Ok solved

On my tests
value=cgsimple::get_root_alias()
or
cgsimple::get_root_alias()
are same working

But I must write after <head> and </__body>
{global_content name="languagestrings_`$rootlang`"}

Thanks for correction on CGSimpleSmarty module