espenmn
(Espen)
1
IN manifest.cfg I can (probably) get the color like this:
csscolor = python:portal_state.portal().portal_registry['My.Addon.interfaces.IMyAddonSettings.color1']
How can I get this into my theme (withouth using themefragments as I have done before):
So basically, I just want to add:
<style>.someclass {background-color: $csscolor; } </style>
PS: I just need one color
I have done this registering a viewlet for plone.app.layout.viewlets.interfaces.IHtmlHead
manager
ZCML:
<browser:viewlet
for="*"
name="my.addon.htmlhead.custom_css"
class=".custom_css.CustomCssViewlet"
template="custom_css.pt"
manager="plone.app.layout.viewlets.interfaces.IHtmlHead"
permission="zope2.View"
layer="...IMyLayer"
/>
PYTHON:
class CustomCssViewlet(ViewletBase):
""" CustomCssViewlet
"""
def update(self):
super().update()
self.color = api.portal.get_registry_record('prefix.color')
TEMPLATE:
<style tal:condition="view/color">
:root {
--my-variable: ${view/colour};
}
</style>