开发者

Customize a document_view and add a div?

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&开发者_JS百科gt;

        <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>


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.


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"?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜