Search code examples
plonezopeploneformgen

PloneFormGen Header Injection Example


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..


Solution

  • 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>