Forums / Developer / Variables scope / Comment39629

Author Topic

Paul Borgermans

Thursday 15 January 2004 11:13:15 am

Comment39629

Hi Shurbann

---edited---
Changed the
{section show=$array|contains($Section1:item)|not} into
{section show=eq($var,$Section1:item)|not}
to guess what you wanted
--------------

Your example is full of errors, this works (copy and paste, the comments explain your errors):

{let var=1
array=array(1,2,3,1,4) }
{* use array=... , not $array= in let constructs*}
{* arrays need the array creator operator *}
{section name=Section1 loop=$array}
{$var}
{*this will display 1 for every time the loop gets executed , ie 5 times a 1*}
{section show=$array|contains($var)|not}
{* use the notoperator always with {$something|not} *}
{* even more : don't surround anything with parenthesis for evaluation by not, just read from left to right *}
{* what do you want to do here? it is always false*}
{*
you probably wanted to do
{section show=eq($var,$Section1:item)|not}
....
{/section}
*}
{/section}
{/section}
{/let}

More in the upcoming book on Exponential ;-)

hth

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans