plonezopeviewlets

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?


Solution

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