使用带有主题的diazo将类添加到body标签

时间:2012-11-16 16:01:05

标签: xslt plone diazo

我想知道如何使用设置了主题的Diazo为body标签添加一个类。 我会使用if-content检查portal-column-two是否存在,并根据此情况将一个类放入正文标记。

一个解决方案是:

<replace theme="/html/body/@class">
  <xsl:attribute name="class"><xsl:copy-of select="." /> three_col</xsl:attribute>
</replace>

并在此处描述: Add class to body tag using diazo with notheme但只有在设置了notheme时才有效。

那么如何在运行中将一个简单的附加css类放入body标签?

编辑: 这适用于纯粹的重氮与主题和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>

根据条件:

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

我的最终解决方案如下所述:https://plone-theming-with-diazo.readthedocs.org/en/latest/snippets_diazo/recipes/index.html#add-css-class-depending-on-existing-portal-columns