I've been hitting this problem now and then, and never found a decent solution for it.
I have a viewlet that I want to customize for a specific view, of the several where the viewlet is shown on.
My first approach is to try to find the name of the view (as configured in ZCML).
So that given something like:
<browser:viewlet name="plone.htmlhead.title" for="*" manager="plone.app.layout.viewlets.interfaces.IHtmlHead" class="my.addon.viewlets.title.MyTitleViewlet" permission="zope2.View" />
TitleViewlet have something like:
from plone.app.layout.viewlets.common import TitleViewlet class MyTitleViewlet(TitleViewlet): def update(self): if self.XXX == 'my-view': self.site_title = 'a custom title' elif self.YYY == 'another-view' self.site_title = 'another title' else: self.site_title = 'fallback value'
Would be great if one could do that from within the template as well:
<metal:head_slot fill-slot="head_slot"> <title>Blue New Deal</title> </metal:head_slot>
But given that on
main_template.pt we have:
<div tal:replace="structure provider:plone.htmlhead" />
The viewlets take precedence I guess