Forums / Setup & design / If statement with or?
Ben Overmyer
Thursday 18 March 2010 8:34:40 am
I'm attempting to write a conditional statement in template code that accomplishes the following (pseudocode):
if (class.textline == 'string' OR class.textline == 'different string') { dostuff }
Code similar to the above doesn't seem to work, and I can find no documentation on OR logic in eZ Publish conditionals. Little help?
Nicolas Pastorino
Thursday 18 March 2010 8:43:12 am
HI Ben,
This would be something like this :
{if or( eq( $myString, 'string' ), eq( $myString, 'different string' ) )} {* do stuff here *} {/if}
More on the operator there : http://ez.no/doc/ez_publish/technical_manual/4_x/reference/template_operators/logical_operations/or
Cheers !
-- Nicolas Pastorino Director Community - eZ Member of the Community Project Board eZ Publish Community on twitter: http://twitter.com/ezcommunity t : http://twitter.com/jeanvoye G+ : http://plus.tl/jeanvoye
Thursday 18 March 2010 8:48:05 am
Ah, I see.
What if I want to match only a part of the variable? For example:
if ($myvar.contains('string')) { doStuff; }
Thursday 18 March 2010 9:09:57 am
Hei Ben,
What you are looking for is this : http://ez.no/doc/ez_publish/technical_manual/4_x/reference/template_operators/strings/contains
Happy string parsing,Cheers,
Thursday 18 March 2010 9:12:36 am
Exactly what I was looking for, thanks much!!