Forums / Developer / Checking Length of variable
Tony Stark
Monday 21 April 2008 9:58:54 am
Sounds like a noob question (and I am) but if I have the following:
{def $mytext=$this_object.data_map.mydata.content.output.output_text|strip_tags()}
how can I check the length of $mytext and make decisions on it?
i.e. to check if $mytext is greater than 0?
thanks
Tony
Felix Laate
Monday 21 April 2008 11:40:01 am
Hi Tony,
you could use the count_chars-operator:
http://ez.no/doc/ez_publish/technical_manual/4_0/reference/template_operators/strings/count_chars
{if gt($mytext|count_chars,'0')} your code.. {/if}
Felix
Publlic Relations Manager Greater Stavanger www.greaterstavanger.com
Maxime Thomas
Monday 21 April 2008 11:39:15 pm
Or in a prefixed way :
{if $mytext|count()|gt(0)} ... {/if}
Maxime Thomas [email protected] | www.wascou.org | http://twitter.com/wascou Company Blog : http://www.wascou.org/eng/Company/Blog Technical Blog : http://share.ez.no/blogs/maxime-thomas