Re: [SMARTY] can someone tell me what this means?

From: Date: Mon, 09 Dec 2002 17:08:47 +0000
Subject: Re: [SMARTY] can someone tell me what this means?
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6709@lists.php.net to get a copy of this message
Use it like this: {section ...} <tr bgcolor="{cycle values=#comment_bg#}"> ... </tr> {/section} You config file would look like this: comment_bg = #eeeeee,#dddddd On Mon, 2002-12-09 at 08:55, Lee Doolan wrote: > >>>>> "Monte" == Monte Ohrt <monte@ispi.net> writes: > > Monte> cycle is used to cycle through a list of values. What don't > Monte> you understand? > > I'm sorry. I guess my question was not very specific. Let's put it > in definite terms. > > I have a smarty template with a section loop which outputs rows of > HTML and I'd like the rows to have alternating background colors. It > seems to me that {cycle} would be the right thing to use in this case. > > At first I was confused by the assign attribute which appears to take > the name of a template variable rather than a boolean value --am I > right in this?--. Now, it seems that I am having trouble with config > file variables: > > > This code works, but it is kind of klunky: > > {assign var=BG_COLOR value=#COMMENT_BAR1#} > {section name=i loop=$UserHistory->dpyCommentsAry} > > [. . .] > > <tr bgcolor={$BG_COLOR}><td> > {$UserHistory->dpyCommentsAry[i].name}&nbsp; > {$entImage}&nbsp; > {$UserHistory->dpyCommentsAry[i].rest} > </td></tr> > {if $BG_COLOR == #COMMENT_BAR1#} > {assign var=BG_COLOR value=#COMMENT_BAR2#} > {else} > {assign var=BG_COLOR value=#COMMENT_BAR1#} > {/if} > {/section} > > > > This code is sleek but it doesn't work --the background color is not > even close to one of the corect background colors: > > {section name=i loop=$UserHistory->dpyCommentsAry} > {cycle values="#COMMENT_BAR1#,#COMMENT_BAR2#" assign=BG_COLOR} > [. . .] > <tr bgcolor={$BG_COLOR}><td> > {$UserHistory->dpyCommentsAry[i].name}&nbsp; > {$entImage}&nbsp; > {$UserHistory->dpyCommentsAry[i].rest} > </td></tr> > {/section} > > and yet I've verified that the template variable BG_COLOR does toggle > back and forth between #COMMENT_BAR1# and #COMMENT_BAR2# in the second > snippet of code. > > thanks in advance for any help. > > --lee > > -- > Flowers of morning glory. +-----------------------------------------+ > The sky above this street |donate to causes I care about: | > Begins to overcast. | > http://svcs.affero.net/rm.php?r=leed_25 | > --Sugita +-----------------------------------------+ -- Monte Ohrt <monte@ispi.net>

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