I wonder how I can add a class to body tag using Diazo with theme is set.
I'll use if-content
to check if the portal-column-two
exist or not and depending on this put a class into body tag.
One solution is:
<replace theme="/html/body/@class">
<xsl:attribute name="class"><xsl:copy-of select="." /> three_col</xsl:attribute>
</replace>
and is described here: Add class to body tag using diazo with notheme but works only if notheme is set.
So how can I put a simple additional css class into the body tag on the fly?
EDIT: This works with pure Diazo with theme and in Plone (plone.app.theming):
<before theme-children="/html/body"><xsl:attribute name="class"><xsl:value-of select="/html/body/@class" /> three_col</xsl:attribute>
</before>
And based on condition:
<before theme-children="/html/body" css:if-content="#portal-column-two">
<xsl:attribute name="class"><xsl:value-of select="/html/body/@class" /> three_col</xsl:attribute>
</before>
<before theme-children="/html/body" css:if-not-content="#portal-column-two">
<xsl:attribute name="class"><xsl:value-of select="/html/body/@class" /> two_col</xsl:attribute>
</before>
My final solution is described here: https://plone-theming-with-diazo.readthedocs.org/en/latest/snippets_diazo/recipes/index.html#add-css-class-depending-on-existing-portal-columns
The solution used by @MrTango is described here: https://plone-theming-with-diazo.readthedocs.org/en/latest/snippets_diazo/recipes/index.html#add-css-class-depending-on-existing-portal-columns
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With