2010-08-12 92 views
0

这里是我的模板代码:Smarty模板 - 多类

<li class="{$product.name}" {if $product.name == $filter_product.name}class=active{/if}"> 

我希望能够设置$product.name作为类,而当$product.name是有源滤波器还添加类"active"

回答

0

找到自己的答案:

{if $product.name == $filter_product.name} 
    <li class="active {$product.name}"> 
{else} 
    <li class="{$product.name}"> 
{/if} 
0

您只能拥有一个类属性,但它可以包含多个类 - 使用空格分隔它们。因此,在你的例子:

<li class="{$product.name}{if $product.name == $filter_product.name} active{/if}"> 
+0

Smarty的只输出第一$ product.name类。 – CLiown 2010-08-12 16:05:36