Re: [SMARTY] can someone tell me what this means?
| From: | sweatjejm at mchsi dot com | Date: | Mon, 09 Dec 2002 16:53:11 +0000 |
| Subject: | Re: [SMARTY] can someone tell me what this means? | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-6708@lists.php.net to get a copy of this message | ||
I use template code that looks like the following:
<tr align="left" style="background-color: rgb({cycle delimiter="|"
values="255,255,255|255,255,255|230,230,230"})">
This is not tested, but you should be able to
make a single config var that looks like:
COMMENT_BAR_COLORS = "255,255,255|230,230,230"
Then do:
<tr style="background-color: rgb({cycle delimiter="|"
values=#COMMENT_BAR_COLORS#})">
> >>>>> "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 +-----------------------------------------+
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>