Re: How do I evaluate this?

From: Date: Sun, 17 Mar 2002 13:18:58 +0000
Subject: Re: How do I evaluate this?
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3104@lists.php.net to get a copy of this message
> $moduledata_custommenu_main[standard].description|truncate:2 I located the problem. By using {if $myvar|truncate:2:"":true == "--"} I get the expected result. I just had to read to documentation more carefully. I was unaware of smarty locating the nearest word boundry and inserting "..." by default. Sorry. Best Regards Jan H. Andersen -----Oprindelig meddelelse----- Fra: mohrt@ns3.ispi.net [mailto:mohrt@ns3.ispi.net]Pa vegne af Monte Ohrt Sendt: 15. marts 2002 20:59 Til: smarty@lists.ispi.net Cc: smarty@lists.ispi.net Emne: [smarty] Re: How do I evaluate this? Ok, print out the value of $moduledata_custommenu_main[standard].description|truncate:2 and $moduledata_custommenu_main[standard].description check that the values are what you expect them to be. the debug console will give you the second one, you'll have to print the first on the template somewhere. "Jan H. Andersen" wrote: > > It just evaluates wrong. It always results in "-1" being printed, even when > the $moduledata_custommenu_main[standard].description variable starts with > "--". No error messages are printed. > > Nothing changes when the |truncate:2 part is removed. > > Best Regards, > > Jan H. Andersen > > -----Oprindelig meddelelse----- > Fra: mohrt@ns3.ispi.net [mailto:mohrt@ns3.ispi.net]Pa vegne af Monte > Ohrt > Sendt: 15. marts 2002 18:50 > Til: smarty@lists.ispi.net > Cc: smarty@lists.ispi.net > Emne: [smarty] Re: How do I evaluate this? > > Does it give an error, or just evaluate wrong? If you remove the > "|truncate:2" part, does that do something different? > > "Jan H. Andersen" wrote: > > > > >Get rid of the nested brackets. > > > > I tried that too, but it didn't work. The entire section of code look like > > this: > > > > {section name=standard loop=$moduledata_custommenu_main} > > {if $moduledata_custommenu_main[standard].url <> > > ""}"TEXT:{$moduledata_custommenu_main[standard].description}" > > "{if > > $moduledata_custommenu_main[standard].parent == 0}1{else}{if > > $moduledata_custommenu_main[standard].description|truncate:2 == > > "--"}2{else}-1{/if}{/if}" "1" > > "LINK:{$moduledata_custommenu_main[standard].url},content" "" > > {/if} > > {/section} > > > > Sorry about the messy code... It writes a textfile for a menu-applet, with > > one line per menu entry. > > > > Best Regards > > > > Jan H. Andersen > > > > -----Oprindelig meddelelse----- > > Fra: mohrt@ns3.ispi.net [mailto:mohrt@ns3.ispi.net]Pa vegne af Monte > > Ohrt > > Sendt: 15. marts 2002 18:26 > > Til: smarty@lists.ispi.net > > Cc: smarty@lists.ispi.net > > Emne: [smarty] Re: How do I evaluate this? > > > > Get rid of the nested brackets. > > > > {if $myvar|truncate:2 eq "--"}2{else}-1{/if} > > > > "Jan H. Andersen" wrote: > > > > > > I need to do something like this: > > > > > > {if {$myvar|truncate:2} eq "--"}2{else}-1{/if} > > > > > > As far as I know, I cant write it like this in Smarty. When $myvar > > contains > > > "--" as the first 2 characters I want to print "2" else > > > "1". > > > > > > How can I make such an evaluation? > > > > > > Best Regards > > > > > > Jan H. Andersen > > > > > > --- > > > You are currently subscribed to smarty as: monte@ispi.net > > > To unsubscribe send a blank email to $subst('Email.Unsub') > > > Visit Smarty's homepage at > > > http://www.phpinsider.com/php/code/Smarty/ > > > > -- > > Monte Ohrt <monte@ispi.net> > > Director of Technology, ispi Inc. > > > > --- > > You are currently subscribed to smarty as: jha@sjovide.dk > > To unsubscribe send a blank email to $subst('Email.Unsub') > > Visit Smarty's homepage at > > http://www.phpinsider.com/php/code/Smarty/ > > > > --- > > You are currently subscribed to smarty as: monte@ispi.net > > To unsubscribe send a blank email to $subst('Email.Unsub') > > Visit Smarty's homepage at > > http://www.phpinsider.com/php/code/Smarty/ > > -- > Monte Ohrt <monte@ispi.net> > Director of Technology, ispi Inc. > > --- > You are currently subscribed to smarty as: jha@sjovide.dk > To unsubscribe send a blank email to $subst('Email.Unsub') > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/ > > --- > You are currently subscribed to smarty as: monte@ispi.net > To unsubscribe send a blank email to $subst('Email.Unsub') > Visit Smarty's homepage at > http://www.phpinsider.com/php/code/Smarty/ -- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc. --- You are currently subscribed to smarty as: jha@sjovide.dk To unsubscribe send a blank email to $subst('Email.Unsub') Visit Smarty's homepage at http://www.phpinsider.com/php/code/Smarty/

« previous php.smarty.general (#3104) next »