我想在Plone3 + collective.xdv中为某些表单设置样式,但是我不希望所有表单都具有特殊样式.
I want to style some forms in Plone3+collective.xdv but I don't want all forms to get the special style.
所以我想在显示某些模板时向body元素的class属性添加特殊的styled-form类名称:
So I'd like to add a special styled-form class name to the class attribute of the body element just when displaying certain templates:
- 联系信息
- sendto_form
- PFG表格
所以我认为我可以设法用XDV执行此操作,以便不修改那些模板.
So I thought that I could manage to perform this with XDV in order not to modify those templates.
通过使用XDV规则中的if-content指令,我可以检查是否显示了这些模板:
By using the if-content directives in XDV rules I can check if those templates are being displayed:
css:if-content="body.template-contact-info"例如
.
但是我没有找到方法来保持Plone提供的 class属性并根据该条件添加特殊的类.
But I don't find the way to keep the class attribute as delivered by Plone and add the special class based on that condition.
我想要的结果将是:
<body class="template-contact-info styled-form"> ... </body>提前谢谢.
推荐答案使用Diazo/plone.app.theming,您可以合并模板和内容中的属性,请参见: diazo/basic.html#merge
With Diazo/plone.app.theming you can merge attributes from the template and content, see: diazo/basic.html#merge
如果您无法升级,则需要使用内联XSL进行此操作,例如:
If you can't upgrade then you'll need to do this with inline XSL, something like:
<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>更新:我在上面的示例中忘记了标签.现在应该可以使用了.
Update: I forgot the tag in the example above. It should work now.
更多推荐
使用XDV将类添加到body元素
发布评论