3

I want to style some forms in Plone3+collective.xdv but I don't want all forms to get the special style.

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:

  • contact-info
  • sendto_form
  • PFG forms

So I thought that I could manage to perform this with XDV in order not to modify those templates.

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"

for instance.

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.

My desired result would be something like:

<body class="template-contact-info styled-form">
    ...
</body>

Thanks in advance.

Lennart Regebro
  • 167,292
  • 41
  • 224
  • 251
marcosfromero
  • 2,853
  • 17
  • 17

1 Answers1

3

With Diazo/plone.app.theming you can merge attributes from the template and content, see: http://diazo.org/basic.html#merge

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.

Laurence Rowe
  • 2,909
  • 17
  • 20
  • This *almost* works. It adds the a text node with the resulting values: ``template-contact-info styled-form ... `` How can I tell XDV to insert that inside the ``class`` attribute? – marcosfromero Jul 06 '11 at 17:56
  • I think you can get that with: styled-form – Davi Lima Jul 06 '11 at 18:46
  • @davi-lima: no, apparently ``theme`` doesn't accept attributes but whole elements. I think that the ``merge`` rule of Diazo should workd. But I don't have diazo, but collective.xdv – marcosfromero Jul 06 '11 at 20:08