Tal条件,定义同一行内的多个条件

时间:2012-10-11 12:11:56

标签: php phptal template-tal

我可以选择以下方式:

...
<div class="abc" tal:condition="this/condition1">
    <div class="abc2" tal:condition="this/condition2">
    ...
    </div>
</div>
...

如:

...
<div class="abc" tal:condition="this/condition1 AND this/condition2">
...
</div>
...

1 个答案:

答案 0 :(得分:4)

这有点傻,但在TALES中没有合乎逻辑的AND。

您可以使用php:前缀:

<div tal:condition="php:this.condition1 AND this['condition2']">

但请注意,使用php:时,您需要使用与类型相关的语法(.表示对象,[]表示数组,因为/成为分区。 / p>