3

PloneFormGen allows to inject custom data into the web page header with so-called Header Injection. the description is:

This override field allows you to insert content into the xhtml head. The typical use is to add custom CSS or JavaScript. Specify a TALES expression returning a string. The string will be inserted with no interpretation. PLEASE NOTE: errors in the evaluation of this expression will cause an error on form display.

i wonder what is proper syntax of such expression.. i did not succeed with following example

<style type="text/css"> * { color: red !important; } </style>

neither with

<style tal:attributes="type:text/css" tal:content="* { color: red !important; }">

neither with

<style tal:attributes="type:text/css" tal:content="string:* { color: red !important; }">

neither with

<style tal:attributes="type string:text/css" tal:content="string: * { color: red !important; }" />

the error message informs me only that it has errors..

mykhal
  • 19,175
  • 11
  • 72
  • 80

1 Answers1

4

The field is interpreted as a TALES expression; the results of that expression are what will be inserted. None of your examples are TALES expressions; the last 3 each do use TALES expressions as part of a larger TAL template statement though.

In your case, all you need is a string: expression to return a static result:

string:<style type="text/css"> * { color: red !important; } </style>
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • 2
    Also, see an example of injecting a whole file at http://plone.org/products/ploneformgen/documentation/how-to/restyle-a-form – SteveM Aug 30 '12 at 16:47
  • Steve, That link appears to be broken. Can you point it to the new location of that example? – Joe Bigler Mar 25 '16 at 18:38
  • @JoeBigler: see http://docs.plone.org/working-with-content/managing-content/ploneformgen/restyle.html#an-alternative-way-to-inject-css – Martijn Pieters Mar 25 '16 at 18:43