如何在plone默认主页中使用tal语句?

时间:2014-09-03 06:45:30

标签: python plone

我在zmi页面上创建了简单的静态网站。我需要在plone首页获得python的返回值。我把tal语句放在首页/编辑并保存。但它不起作用。然后我用相同的路径检查,现在这里没有任何有关语句。 我的代码是

<div tal:define="address context/@@address-view" >
  <span tal:define="li address/myaddress" >
    <span tal:replace="structure python:li" />
  </span>
</div>

1 个答案:

答案 0 :(得分:5)

据我所知,你做了什么。

我猜你只是修改了Plone&#34;前页&#34; item,这是一个ATDocument。 出于安全原因,您无法直接在常规ContentType(TextField)中执行tal

您必须在ZMI中创建自己的ZPT视图(处理精细: - ))

  1. 转到http://plonesite/manage_main
  2. 添加&#34;页面模板&#34; - 将其命名为index_html(删除plone的默认首页)。同时删除已放置在新创建的页面模板中的代码。
  3. 使用plone主宏,因此您的代码将位于内容或主插槽中。
  4. <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>
    
    1. 保存 - 完成了。