自定义一个document_view并添加一个div?

发布于 2024-12-06 09:36:47 字数 667 浏览 0 评论 0原文

这感觉像是一个新手问题,但是:

我正在尝试从下拉显示菜单创建一个新页面,以便我可以为页面提供背景颜色(因此最终用户不必进入 html 并添加分区)。我尝试向模板添加一个新的(空)div,但它不起作用。这可能吗?

这是我的代码(我的 div 称为“s_holder”):

 <metal:field use-macro="python:here.widget('text', mode='view')">
Body text
        </metal:field>

        <div metal:use-macro="here/document_relateditems/macros/relatedItems">
            show related items if they exist
        </div>

        <div tal:replace="structure provider:plone.belowcontentbody" />

    </tal:main-macro>
</metal:main>
 <div id="s_holder"></div><!--end s holder-->
</body>
</html>

This feels like a newbie question but:

I am trying to create a new page from the drop-down display menu so that I can supply a background color to the page (so end user doesn't have to go into the html and add a div). I tried adding a new (empty) div to the template but it's not working. Is this even possible?

Here is my code (my div is called "s_holder"):

 <metal:field use-macro="python:here.widget('text', mode='view')">
Body text
        </metal:field>

        <div metal:use-macro="here/document_relateditems/macros/relatedItems">
            show related items if they exist
        </div>

        <div tal:replace="structure provider:plone.belowcontentbody" />

    </tal:main-macro>
</metal:main>
 <div id="s_holder"></div><!--end s holder-->
</body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三月梨花 2024-12-13 09:36:47

对于创建新显示视图的部分:正如@Auspex所说,您应该将div放在宏内。

要将显示视图添加到下拉菜单,您需要编辑每种内容类型。有两种方法可以做到这一点:

1- 在产品的 genericsetup 配置文件中手动添加一个“types”文件夹,并为每种内容类型放入一个 xml 文件。例如:

File.xml

<?xml version="1.0"?>
<object name="File"
    meta_type="Factory-based Type Information with dynamic views"
    i18n:domain="plone" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
    <property name="view_methods">
        <element value="file_view"/>
        <element value="myniewfantastic_view"/>
    </property>
</object>

2- 在 ZMI 中 -> Portal_types 编辑每个内容类型以添加​​显示视图,然后在 Portal_setup 工具中导出类型的步骤。将 xml 定义从下载的存档中提取到 genericsetup 配置文件(在“types”文件夹中),然后编辑它们以删除无用的部分,如上所述。

For the part of creating the new display view: as @Auspex said, you should put the div inside the macro.

To add your display view to the drop down menu you need to edit every content type. There are two ways of doing this:

1- manually add a "types" folder in the genericsetup profile of your product and put inside one xml file per content type. Ex:

File.xml

<?xml version="1.0"?>
<object name="File"
    meta_type="Factory-based Type Information with dynamic views"
    i18n:domain="plone" xmlns:i18n="http://xml.zope.org/namespaces/i18n">
    <property name="view_methods">
        <element value="file_view"/>
        <element value="myniewfantastic_view"/>
    </property>
</object>

2- in the ZMI -> portal_types edit every content type to add your display view and then in the portal_setup tool export the step for types. Extract the xml definitions from the downloaded archive to your genericsetup profile (in the "types" folder) and then edit them to remove unuseful parts as above.

王权女流氓 2024-12-13 09:36:47

当然你能做到。我不相信这是一个好主意:-),但你需要

位于 main_macro 的内部(您的示例 HTML 无效 - 您有一个 并且没有开始标记,但我假设您只是剪切并粘贴了此处的模板,因为该模板永远不会显示,如果是这样编写的,

那么您究竟如何将其添加到“下拉显示菜单”中?

Sure you can do it. I'm not convinced it's a good idea :-), but you need the <div> to be inside the main_macro (your example HTML is invalid - you have a </tal:main-macro> and no start tag, but I'm assuming you just cut and pasted the last part of the template here, because that template would never display, if it was written that way.

That said, how exactly are you adding it to "the drop-down display menu"?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文