Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add class to body tag using diazo with theme is enabled

Tags:

xslt

plone

diazo

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

like image 776
MrTango Avatar asked Nov 16 '12 16:11

MrTango


1 Answers

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

like image 64
toutpt Avatar answered Sep 20 '22 05:09

toutpt