Re: Template Variable Question
| From: | Monte Ohrt | Date: | Mon, 04 Mar 2002 17:40:22 +0000 |
| Subject: | Re: Template Variable Question | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2948@lists.php.net to get a copy of this message | ||
Currently it is not part of the template syntax, it must be done as a
function.
{assign var="fontColor" value="888888"}
{$fontColor}
Steve wrote:
>
> I'm trying to figure out how to use a variable in a template. I have the
> following code block to illustrate what I'd like to do:
>
> {if $productList[p]->hidden eq 1}
> <tr bgcolor="#{#hiddenColor#}">
> {$fontColor = "888888"}
> {$linkClass = "greylink"}
> {elseif $smarty.section.p.rownum mod 2 eq 1}
> <tr bgcolor="#{#altRowColor#}">
> {$fontColor = "000000"}
> {$linkClass = "blacklink"}
> {else}
> <tr bgcolor="#ffffff">
> {$fontColor = "000000"}
> {$linkClass = "blacklink"}
> {/if}
>
> And then use the $fontColor and $linkClass in each <td> for this row of a
> table. What is the correct syntax to assign a variable in a template and
> then later echo that variable? I tried $smarty.fontColor = "000000" and
> that didn't work either.
>
> Thank You,
>
> Steve
>
> ---
> 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.