plone + formlib:如何引用form.pt

时间:2022-10-27 07:21:34

I'm working on plone 3.2.1 and I've made a formlib's form with a custom template:

我正在研究plone 3.2.1并且我使用自定义模板制作了一个formlib的表单:

from Products.Five.formlib import formbase
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
...

class MyForm(formbase.PageForm):
    ...

    template = ViewPageTemplateFile('myform.pt')

I want to make a simple change to the standard formlib template. My question is: how do I reference the parts/zope2/lib/python/zope/formlib/pageform.pt inside my template?

我想对标准formlib模板进行简单的更改。我的问题是:如何在模板中引用parts / zope2 / lib / python / zope / formlib / pageform.pt?

<!-- myform.pt -->
<metal:macro metal:use-macro="WHAT GOES HERE??">
  <div metal:fill-slot="extra-info">
    I just want to put a text before the standard formlib template
  </div>
</metal:macro> 

2 个解决方案

#1


Finally, I found the answer:

最后,我找到了答案:

<html xmlns="http://www.w3.org/1999/xhtml"                                            
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      metal:use-macro="context/main_template/macros/master">
<body>
  <div metal:fill-slot="main">
    <div metal:use-macro="context/@@base-pageform.html/macros/form">
      <metal:block fill-slot="extra_info">
        <!-- HERE we go -->
      </metal:block>
    </div>
  </div>
</body>
</html>

#2


Just watch out there (for anyone looking for this, like me): the line:

请注意那里(对于任何寻找此人的人,比如我):行:

<divmetal:fill-slot="main">

needs a space in between div and metal:

在div和金属之间需要一个空间:

<div metal:fill-slot="main">

Thanks; very helpful solution.

谢谢;非常有用的解决方

#1


Finally, I found the answer:

最后,我找到了答案:

<html xmlns="http://www.w3.org/1999/xhtml"                                            
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      metal:use-macro="context/main_template/macros/master">
<body>
  <div metal:fill-slot="main">
    <div metal:use-macro="context/@@base-pageform.html/macros/form">
      <metal:block fill-slot="extra_info">
        <!-- HERE we go -->
      </metal:block>
    </div>
  </div>
</body>
</html>

#2


Just watch out there (for anyone looking for this, like me): the line:

请注意那里(对于任何寻找此人的人,比如我):行:

<divmetal:fill-slot="main">

needs a space in between div and metal:

在div和金属之间需要一个空间:

<div metal:fill-slot="main">

Thanks; very helpful solution.

谢谢;非常有用的解决方