2012-08-30 35 views
3

PloneFormGen允許通過所謂的頭注入將自定義數據注入到網頁頭中。描述是:PloneFormGen頭注入示例

此重寫字段允許您將內容插入到xhtml頭中。 典型用途是添加自定義CSS或JavaScript。指定返回字符串的TALES 表達式。該字符串將被插入,但不會解釋爲 。請注意:評估此 表達式時出現錯誤將導致表單顯示錯誤。

我不知道什麼是這樣表達的正確語法..我沒有與下面的例子

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

既不

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

既不

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

既不成功與

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

錯誤消息通知我只知道它有錯誤 ..

回答

4

該字段被解釋爲TALES表達;該表達式的結果將被插入。你的例子中沒有一個是TALES表達式;每個最後3個做使用 TALES表達式作爲更大的TAL模板語句的一部分。

在你的情況,你需要的是一個string:表達式返回一個靜態結果:

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

就是這樣,THX) – mykhal

+2

此外,請參閱HTTP注入整個文件的例子:// Plone的。 org/products/ploneformgen/documentation/how-to/restyle-a-form – SteveM

+0

Steve,該鏈接似乎已被破壞。你能指出它到那個例子的新位置嗎? –