Question

I have a site which has a public url displayed through a plone.app.theming / Diazo theme and url restricted to content editors displayed through sunburst.

I'd like certain portal types to only appear in listings to the cms editors and not on the public site. I notice that the folder_listing template uses request/contentFilter if defined. Is there some way to add a content filter to the request just for the themed view?

Was it helpful?

Solution

I ended up solving this using a pre traversal hook on the Plone site. This worked in my case because I can reliably work out whether a request is for the theme view or editing view based on some properties of the request.

def SetupThemeView(site, before_traverse):
    """ If we're serving the public, themed, version then supplement the request
    """
    request = before_traverse.request
    if serving_theme_view(request):
        request.set('contentFilter', {'portal_type' : listable_types})

Where serving_theme_view determines if we're serving the theme or editor view and listable_types is a tuple of type names of types we want to appear in listings in the theme view.

I then register this as a subcriber in my configure.zcml

<subscriber
    for="Products.CMFCore.interfaces.ISiteRoot
         zope.traversing.interfaces.IBeforeTraverseEvent"
    handler=".events.SetupThemeView"
    />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top