plone - 使用带有 notheme 的 diazo 将类添加到 body 标签

标签 plone diazo

我正在使用叠加层显示文档的内容 plone/document?ajax_load=True&ajax_include_head=True作为 iframe 的 src。

在开发模式中追加&diazo.off=1成功了。 在生产服务器上这很遗憾不起作用,所以我添加了 documentation of plone.app.theming 中建议的 ajax_load 参数

我将我所有的指令包装在一个 <rules if-not="$ajax_load"> 中元素以确保它们不被应用(参见下面的代码)

现在我需要用特定的类标记 iframed 页面的主体以应用不同的样式(例如,覆盖中的主体没有背景颜色)

nearly similar question 提出的解决方案仅当您将主题与具有要操作的类属性的主体元素一起使用时才有效。

有没有办法在没有主题的情况下向内容添加类(使用 )? 还是我必须提供一个空的 html 文档 (index2.html) 作为主题并应用大量规则来复制 css/js 等两次?

<rules if="$ajax_load">

    <!-- theme href="index.html" /-->

    <notheme />


    <!-- only works when using a theme -->
    <before theme-children="/html/body"><xsl:attribute name="class"><xsl:value-of select="/html/body/@class"/> my class</xsl:attribute></before>


    <!-- thought this could to the trick but does not work at all -->
    <xsl:template match="html/body">
    <xsl:attribute name="class"> foo</xsl:attribute>
    </xsl:template>


</rules>

<rules if-not="$ajax_load">


    <theme href="index.html" />

    <replace content="/html/head/title" theme="/html/head/title" />
    ...

最佳答案

显然没有主题可以操作,任何引用主题的规则都不能与 <notheme/> 结合使用.但是你可以 <drop><replace>内容(我有关于如何实现 <before><after> 内容的想法,但它很难实现。也许在 Diazo 的 future 版本中。)但是你可以用少量的 xslt 实现同样的事情:

<replace content="/html/body/@class">
    <xsl:attribute name="class"><xsl:value-of select="."/> newclass</xsl:attribute>
</replace>

关于plone - 使用带有 notheme 的 diazo 将类添加到 body 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11672440/

相关文章:

testing - 如何在 Plone 的测试中打印内容

css - Diazo 规则拆分列中的内容

plone - 在 content-children 之后插入标签

python - 导入错误: cannot import name IPossibleSitenterfaces import IPossibleSite: version mismatch?

plone - 使 Plone 4.1 中的匿名用户可以查看成员肖像

portlet - 在 Plone 中禁用站点范围内的 portlet 类型

plone - 在 Diazo 中使用什么代替 HTTP_X_XDV?

xsd - plone.app.theming 包括来自外部站点的内容

plone - 使用 Diazo 即时删除属性

Plone 4.3 运行 Buildout 时出现断言错误