我在zmi页面上创建了简单的静态网站。我需要在plone首页获取python的返回值。我将 tal 语句放在首页/编辑中并保存。但它不起作用。然后在我检查相同的路径后,现在 tal 语句不存在于此处。 我的总代码是
<div tal:define="address context/@@address-view" >
<span tal:define="li address/myaddress" >
<span tal:replace="structure python:li" />
</span>
</div>
最佳答案
据我了解您所做的事情。
我猜你只是修改了 Plone 的“首页”项目,它是一个 ATDocument。
出于安全原因,您无法直接在常规 ContentType (TextField) 中执行 tal
。
您必须在 ZMI 中创建自己的 ZPT View (这可以很好地处理 tal :-))
- 转到
http://plonesite/manage_main
- 添加“页面模板” - 将其命名为
index_html
(删除 plone 的默认首页)。同时删除已放置在新创建的页面模板中的代码。 - 使用 plone master 宏,因此您的代码将放置在内容或主插槽中。
<html i18n:domain="plone"
lang="en"
metal:use-macro="here/main_template/macros/master"
xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:tal="http://xml.zope.org/namespaces/tal">
<body>
<div metal:fill-slot="main">
... YOUR CODE HERE...
</div>
</body>
</html>
- 保存 - 大功告成。
关于python - 如何在plone默认主页中使用tal语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25637900/