Plone 条件取决于其他字段

Plone 条件取决于其他字段,plone,zope,template-tal,zpt,Plone,Zope,Template Tal,Zpt,我有两个字段(字段A和字段B) 我想要的是: -如果字段A包含某些内容,则不应显示字段B 我尝试的是: <span tal:replace="here/getFieldA" /> <span tal:omit-tag="here/getFieldA" tal:replace="here/getFieldB" /> 所以它不起作用 谢谢你的帮助试试看 <span tal:condition="here/getFieldA" tal:replace="her

我有两个字段(字段A和字段B)

我想要的是: -如果字段A包含某些内容,则不应显示字段B

我尝试的是:

<span tal:replace="here/getFieldA" />

<span tal:omit-tag="here/getFieldA"  tal:replace="here/getFieldB" />

所以它不起作用

谢谢你的帮助

试试看

<span tal:condition="here/getFieldA"  tal:replace="here/getFieldB" />


Zope页面模板参考

这是根据评论对原始答案的改进:

<tal:block 
    tal:define="zone here/getZoneintervention;
                thezone python:', '.join(zone);
                dep here/getDepartements;
                thedep python:', '.join(dep)">

   <span tal:condition="zone" tal:replace="thezone" /> 
   <span tal:condition="not:zone" tal:replace="thedep" /> 

</tal:block>

您要查找的是,可能与和前缀结合使用:

<span tal:replace="here/getFieldA" />

<span tal:condition="not:exists:here/getFieldA" tal:replace="here/getFieldB" />
属性的含义非常不同。如果其表达式的计算结果为
True
,则输出中将忽略标记,而仅忽略标记本身。以下是一个最好的例子:

<span tal:omit-tag="">
    <i>This part will be retained</i>
</span>

这一部分将予以保留
呈现该页面模板会导致:

<i>This part will be retained</i>
此部分将保留

省略了周围的
标记,但保留了内容

不是管道操作员的正确描述。如果未找到
之前的元素(因此引发
NotFound
AttributeError
KeyError
),它只查看下一个元素。如果管道之前的表达式返回布尔值
False
(或类似值,如
None
[]
0
)这就是返回的结果!我最近不得不帮助一个误解了运算符性质的人,因为解释不正确。:-)这是我的完整代码:
如果字段Zoneintervention为空,则Martijn的注释后不会显示任何内容来解释为什么会发生这种情况。我的示例依赖于here/getFieldA实际失败,而不仅仅是返回false或空字符串。tal:条件加上“不:”应该是你们的解决方案。如果getZoneintervention总是返回一些内容,请不要在测试中使用“exists:”。
<i>This part will be retained</i>