what works and doesn't with smarty scopes

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
dlen
Forum Members
Forum Members
Posts: 67
Joined: Fri Apr 09, 2010 11:32 pm

what works and doesn't with smarty scopes

Post by dlen »

Hi,

i write this down to try to help others with the same problem.

Situation: Assigned values to smarty variables in template file above the <__html> tag. Used always the attribute "scope=global".

Some variables could be used from down below the </__body> tag, while others couldn't.

Turned out, that

Code: Select all

{varname = some_value scope=global}
{assign name='varname' value=some_value scope=global}
worked, while

Code: Select all

{some_smarty_tag assign='varname' scope=global}
didn't.

Any constructive remark welcome...
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1922
Joined: Mon Jan 29, 2007 4:47 pm

Re: what works and doesn't with smarty scopes

Post by Jo Morg »

dlen wrote: Turned out, that

Code: Select all

{varname = some_value scope=global}
{assign name='varname' value=some_value scope=global}
worked, while

Code: Select all

{some_smarty_tag assign='varname' scope=global}
didn't.
Modules, plugins and UDT's currently don't have a way to recognize the scope parameter, as it only applies to variables. The best way to go around this limitation is:

Code: Select all

{$var="{some_smarty_tag}" scope=global}
Please note that in this case we use the double quotes to make sure whatever we are assigning to the var is evaluated beforehand. On all other situations the best practice is to use single quotes.
Additionally use this article as reference: http://www.cmscanbesimple.org/blog/smar ... e-examples
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
dlen
Forum Members
Forum Members
Posts: 67
Joined: Fri Apr 09, 2010 11:32 pm

Re: what works and doesn't with smarty scopes

Post by dlen »

thanks for the valuable link.
Locked

Return to “[locked] Installation, Setup and Upgrade”