我想在 Plone3+collective.xdv 中设置一些表单的样式,但我不希望所有表单都获得特殊样式。
所以我想在body
元素的class
属性中添加一个特殊的styled-form
类名,只是在显示特定的时候模板:
- 联系信息
- sendto_form
- PFG 表格
所以我认为我可以设法使用 XDV 执行此操作,以免修改这些模板。
通过在 XDV 规则中使用 if-content
指令,我可以检查这些模板是否正在显示:
css:if-content="body.template-contact-info"
例如。
但我找不到保留 Plone 提供的类属性并根据该条件添加特殊类的方法。
我想要的结果是这样的:
<body class="template-contact-info styled-form">
...
</body>
提前致谢。
最佳答案
使用 Diazo/plone.app.theming,您可以合并模板和内容中的属性,请参阅:http://diazo.org/basic.html#merge
如果您无法升级,那么您需要使用内联 XSL 来执行此操作,例如:
<prepend theme="/html/body" css:if-content="body.template-contact-info"><xsl:attribute name="class"><xsl:value-of select="/html/body/@class"/> styled-form</xsl:attribute></prepend>
更新:我忘记了上面例子中的标签。它现在应该可以工作了。
关于plone - 使用 XDV 向 body 元素添加一个类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6599993/