RE: [SMARTY] function alternate
| From: | G | Date: | Thu, 02 May 2002 21:01:14 +0000 |
| Subject: | RE: [SMARTY] function alternate | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-4008@lists.php.net to get a copy of this message | ||
How about replace val1 and val2 with "values" which can accept an array?
Gerard
> -----Original Message-----
> From: Monte Ohrt [mailto:monte@ispi.net]
> Sent: Thursday, May 02, 2002 2:58 PM
> To: Smarty
> Subject: [SMARTY] function alternate
>
>
> I just created a handy function I'd like your input on, called alternate.
>
> example:
>
> {section ...}
> <tr>
> <td bgcolor={alternate val1="#eeeeee" val2="#b0b0b0"}>
> .....
> </td>
> </tr>
> {/section}
>
>
> Each time you call alternate, it will alternate printing val1 and val2.
> In this example, every cell of the table will alternate background
> colors. This is kind of a shortcut for something like this:
>
> {if $smarty.section.foo.index is even}#eeeeee{else}#b0b0b0{/if}
>
> PLUS, if you want to alternate values within one loop of the section
> (like in the above example), you can do so... it is independent of the
> current section loop iteration.
>
> You can optionally supply a "name" attribute in case you have more than
> one alternate tag running in the template. So you can do this:
>
> {alternate name=foo1 val1="do" val2="re"}
> {alternate name=foo2 val1="mi" val2="fa"}
> {alternate name=foo1 val1="do" val2="re"}
> {alternate name=foo2 val1="mi" val2="fa"}
>
> output would be:
>
> do
> mi
> re
> fa
>
> What I'm wondering, is this syntax good? Are the variable names "val1"
> and "val2" the best choice? Should the alternate function be able to
> accomodate three or more values to "alternate" between?
>
> Monte
>
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>