Solution: Inserting inline client script into content using a custom tag

Table of contents:


  • On: Monday 12 March 2007 6:58:37 pm
  • From: Diego Barcia


For a site, I needed to insert JavaScript statements to be parsed and not displayed by the browser, on a page-by-page basis. So I configured a <script> custom tag of an inline type into the content.ini file of the admin and the public siteacceses:


Then, I created a template file in the \templates\content\datatype\view\ezxmltags\ directory (of the site's design), called script.tpl, with this code:


This worked fine. There is no need to wrap the $content variable within {literal} operators; there won't be any trouble using JavaScript curly braces ('{', '}').
The custom tag *must* be of an inline type, or else a parse error will be triggered by the engine, because block tags are printed between <p> tags, so the result would be like: