Diazo theme parameters on theme HTML

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 :sweat_smile:

Is it possible to use a theme variable on the HTML itself?


<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 :confused:

I'm the only one ever having wondered about it? :thinking:

Not that I know of, but a workaround could be to load a theme fragment and use variables there.

@espenmn thanks for the answer! :smile:

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? :sweat_smile:

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

Cool thanks!!

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: