我正在使用叠加层显示文档的内容
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/