简体   繁体   中英

How to get viewlet by an plone object url

I'm trying to get viewlet belowcontenttitle for an object by its URL. Something like below, but using object URL instead of 'plone'.

id="viewlet-below-content-title" tal:content="structure provider:plone.belowcontenttitle"

Can I do it using restrictedTraverse?

Your best bet is to create a new view for the belowcontenttitle viewlet; template:

<div tal:content="structure provider:plone.belowcontenttitle"/>

registered with:

<browser:page
    for="*"
    name="belowcontenttitle"
    permission="zope2.View"
    template="template_shown_above.pt"
    />

Then you can use that view with a simple traverse:

<div tal:replace="structure context/path/to/other/object/@@belowcontenttitle" />

This looks up the view in the context of the other object; the template is rendered and returned, replacing the div .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM