我想知道如何使用设置了主题的Diazo为body标签添加一个类.我将if-content用来检查是否portal-column-two存在并依赖于此将一个类放入body标签中.
一个解决方案是:
<replace theme="/html/body/@class">
<xsl:attribute name="class"><xsl:copy-of select="." /> three_col</xsl:attribute>
</replace>
Run Code Online (Sandbox Code Playgroud)
并在此处描述: 使用带有notheme的重氮将类添加到body标签,但仅在设置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>
Run Code Online (Sandbox Code Playgroud)
并根据条件:
<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>
Run Code Online (Sandbox Code Playgroud)
我的最终解决方案如下所述:https://plone-theming-with-diazo.readthedocs.org/en/latest/snippets_diazo/recipes/index.html#add-css-class-depending-on-existing-portal-columns