gforcada
(gforcada)
April 19, 2022, 10:44am
1
I read about how to use diazo theme parameters as well as on its official documentation , but I'm missing a use case, that for me is quite obvious
Is it possible to use a theme variable on the HTML itself?
i.e.
<a href="${portal_url}/login">Log in here</a>
<a href="${portal_url}/register">Register</a>
To me it feels much more clear and straightforward than having to use a diazo rule to target these two links to change their href attribute
I'm the only one ever having wondered about it?
espenmn
(Espen)
April 19, 2022, 4:34pm
2
Not that I know of, but a workaround could be to load a theme fragment and use variables there.
gforcada
(gforcada)
April 20, 2022, 12:43am
3
@espenmn thanks for the answer!
Theme fragments... I remember reading about them, but never actually used any, is this an extra package, or plone core? where does it live? any example around?
espenmn
(Espen)
April 20, 2022, 8:04am
4
I am not sure if it is part of core (since I always include Mosaic). You probably need to include collective.themefragments
The approach is quite simiple, you include a 'fragments' folder in your theme and place .pt files there (which can include TAL etc). You can also have .py file, so basically it is a bit similar to browser views, but without any 'setup' (and using restricted python). In your rules you include them like this:
<replace css:theme="#main-slider" css:content="#main-slider" href="/@@theme-fragment/mainslider" />
PS: If you (bother to) make a browser view, you can do (something) like this
<replace css:theme="#portal-mobile-sitemap" css:content="#portal-mobile-sitemap" href="/@@mobile_sitemap" />
1 Like
espenmn
(Espen)
April 20, 2022, 12:17pm
6
Although this theme is outdated, you might find 'examples' / snippets you can look at here: GitHub - collective/collective.multitheme: A multi purpose Plone 5 theme for Mosaic and Themingfragments
For example this line: collective.multitheme/rules.xml at master ยท collective/collective.multitheme ยท GitHub
Which loads:
<style id="customcss">
<tal:define
tal:define="color1 python: str(context.portal_registry['collective.multitheme.interfaces.ICollectiveMultiThemeSettings.color1']);
color2 python: str(context.portal_registry['collective.multitheme.interfaces.ICollectiveMultiThemeSettings.color2']);
color3 python: str(context.portal_registry['collective.multitheme.interfaces.ICollectiveMultiThemeSettings.color3'])">
option[value=custom-color1], .custom-color1 {color: #${color1} !important}
option[value=custom-color2], .custom-color2 {color: #${color2} !important}
option[value=custom-color3], .custom-color3 {color: #${color3} !important}
option[value=custom-background1], .custom-background1 {background-color: #${color1} !important}
option[value=custom-background2], .custom-background2 {background-color: #${color2} !important}
option[value=custom-background3], .custom-background3 {background-color: #${color3} !important}
</tal:define>
</style>