Re: [SMARTY] can someone tell me what this means?
| From: | Lee Doolan | Date: | Mon, 09 Dec 2002 14:55:47 +0000 |
| Subject: | Re: [SMARTY] can someone tell me what this means? | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6707@lists.php.net to get a copy of this message | ||
>>>>> "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}
{$entImage}
{$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}
{$entImage}
{$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 +-----------------------------------------+