I have defined a own LayoutPolicy Class to extends the CSS Classes in the Body-Tag.
<!-- Extends the CSS Body Classess -->
<browser:page
name="plone_layout"
for="*"
permission="zope.Public"
class=".layout.LayoutPolicy"
layer="my.addon.interfaces.IMyAddonInstalled"
allowed_interface="plone.app.layout.globals.interfaces.ILayoutPolicy" />
I have also installed the collective.cover Plugin. In this Package is also a LayoutPolicy Class :
<browser:page
name="plone_layout"for="collective.cover.interfaces.ICover"
permission="zope.Public"
class=".layoutpolicy.LayoutPolicy"
allowed_interface="plone.app.layout.globals.interfaces.ILayoutPolicy"
layer="collective.cover.interfaces.ICoverLayer" />
The Policy from collective.cover :
# -*- coding: utf-8 -*-
from plone.app.layout.globals import layout as base
from plone.i18n.normalizer.interfaces import IIDNormalizer
from zope.component import getUtility
class LayoutPolicy(base.LayoutPolicy):
"""Override the default Plone layout utility."""
def bodyClass(self, template, view):
"""Include layout identifier in bodyClass."""
body_class = super(LayoutPolicy, self).bodyClass(template, view)
util = getUtility(IIDNormalizer)
layout_id = util.normalize(self.context.template_layout)
return 'cover-layout-{0} {1}'.format(layout_id, body_class)
My Problem, on all Contenttype Pages my Policy matched. But on the Cover-Site it doesn't. I know why, because my Class/Method isn't calling.
Is there a possibility to merge this two Policies via zcml or override/extends... or whatever? Had anyone an idea?
My only Solution is to clone the Collective Cover Product and override the Layout Policy in my Filesystem like:
# -*- coding: utf-8 -*-
from my.addon.globals import layout as base
from plone.i18n.normalizer.interfaces import IIDNormalizer
from zope.component import getUtility
class LayoutPolicy(base.LayoutPolicy):
"""Override the default Plone layout utility."""
def bodyClass(self, template, view):
"""Include layout identifier in bodyClass."""
body_class = super(LayoutPolicy, self).bodyClass(template, view)
util = getUtility(IIDNormalizer)
layout_id = util.normalize(self.context.template_layout)
return 'cover-layout-{0} {1}'.format(layout_id, body_class)