Re: def using namespaces
{set} is not {def} ;).
Namespaces are supported by the set function but not by the def statement as mentionned in the documentation.
In other words, you can define a variable and set a value for a specific namespace.
{set} is not {def} ;).
Namespaces are supported by the set function but not by the def statement as mentionned in the documentation.
In other words, you can define a variable and set a value for a specific namespace.
This documentation stores what it needs to work: a session cookie when you sign in or keep a setting such as the help menu shown or hidden, the design you chose (Classic or Modern) and your language. Only if you agree, it also uses Google Analytics (through Google Tag Manager) to count visits; until then nothing is loaded from Google. Your choice is kept in a cookie for 6 months, and you can change it at any time under "Cookie settings" at the foot of every page. Details are in our Cookie Policy.
The session cookie for signing in and for forms, the cookies that keep your design and language, and the cookie that keeps this choice. They stay on because the website needs them; you can delete them in your browser settings at any time.
Google Analytics, loaded through Google Tag Manager (GTM-MPGWKTQV), counts visits and shows us which pages are read: the pages you open, the page you came from, your browser, device and screen size, and your approximate location derived from your IP address. Google processes the data for us and may transfer it to the USA. It sets the cookies _ga and _ga_* for up to 2 years. Off until you turn it on; when you turn it off again, Google is no longer loaded and these cookies are deleted.
Comments (5 historical)
Written by readers of the earlier documentation sites, kept as they were.
Re: Re: def using namespaces
Niels ·
Example 1:
{def name=ns1 $var1='ns1 org value'}
{def name=ns2 $var1='ns2 org value'}
There still ist a name=.. in there.
Re: Re: def using namespaces
Stefano Guandalini ·
Yes, but what if I want to define a variable in the 'root' or 'global' namespace?
The following does not work:
{def $loaded='pippopippo'} {set name=root $loaded='pippopippo'}In this case $root:loaded outputs nothing!
g
How to define global variables
Leif Arne Storset ·
After some forum searching, trial and failure, I found out how to work with global variables. Apparently, 'root' means current template, and 'global' is for exchanging data between templates. :S
You cannot declare a variable as global, so just declare it like a regular variable (definition is compulsory):
{def $total_items=0}To define or set a global variable:
{set scope='global' $total_items=0}To read a global variable:
{$#total_items}To update a global variable, you naturally combine the above:
{set scope='global' $total_items=$#total_items|inc()}Re: How to define global variables
Olav Bringedal ·
Thanks for your research.
It really logical, but I had to try a few times before it got to me:
You need to declare the variable in pagelayout.tpl to access it in templates on same or higher level than the one that sets it.
Re: Re: How to define global variables
Guillaume ·
This doesn't work for me, i can set the var but i cannot get the value.