使用启用主题的Diazo添加类到body标签

7
我想知道如何在使用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>

这里有一个描述如何将类添加到body标签的链接:使用notheme的diazo添加类到body标签,但仅适用于设置了notheme。

那么如何在运行时将简单的附加CSS类放入body标记中呢?

编辑: 这适用于纯Diazo主题和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

本文介绍了一个关于IT技术的方案。如果您想了解更多信息,请点击上面的链接。

1
有点相关,这里是如何使用Python添加body类的方法:http://developer.plone.org/templates_css_and_javascripts/css.html#adding-new-css-body-classes - Mikko Ohtamaa
1
嗨Mikko,谢谢你的回答,但我正在寻找纯Diazo / XSLT解决方案。 - MrTango
我想知道 - 这个问题难道没有被回答吗? - romanofski
1个回答

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接