eZ Documentation Center

This is outdated documentation made for eZ Publish Platform 5.2. It is being moved into the eZ Publish 5.x documentation, so please go there for most up-to-date documentation.

Skip to end of metadata
Go to start of metadata

Version compatibility

This recipe is compatible with eZ Publish 5.2 / 2013.07

Custom tags

XMLText fieldtype supports a limited number of tags in its internal eZXML format to render HTML5. However, it is possible to extend the rendering by implementing custom tags.

As HTML5 rendering in eZ Publish is done through XSLT, you will need to create an XSL stylesheet to extend the rendering.

Note on legacy custom tags

To be able to edit a custom tag from admin interface, you'll still need to register your custom tag in the legacy kernel (at least the configuration part, template not being mandatory for edition).

Register your custom XSL stylesheet

To activate your custom tag rendering, you need to create an XSL stylesheet and to register it properly:


Each entry under custom_tags is a hash having the following properties:


Absolute path to the XSL to import.


Use %kernel.root_dir% parameter to start from ezpublish/ folder.



Priority of your stylesheet in the sequence of importing. The higher it is, the higher precedence it will have.

In XSL imports, in case of template overrides, the last imported XSL always wins. Hence custom XSL are loaded in reverse priority order.

Example of a custom XSL

The following example shows how to render the YouTube embed custom tag from jvEmbed legacy extension (see also related legacy configuration for content).

Note that all selected attributes are in custom namespace (this is the case for all custom tags attributes in internal eZXML).



PHP functions are registered in the XSLTProcessor, so you can use PHP functions and static method calls to enhance the XSLT process (using php-function and php-functionString XSLT functions).

However, consider using those for simple use cases. For more complex cases, you'll need to register pre-converters instead.

Using Pre-converters

Pre-converters are services that pre-process the internal XML before the XSLT rendering occurs. It can be useful if you need to manipulate the data stored in eZXML.

An example of use is what is done for internal links. Indeed, internal location or content are linked by their locationId/contentId which need to be transformed in a usable URI.

Pre-converters receive the whole DOMDocument object for the current field. So you can easily do XPath queries and do some DOM manipulation against it.

Registering a pre-converter

All pre-converters need to:


services.yml in a bundle

Overriding existing XSL templates

As XSL stylesheets apply for the whole resulted DOM, you can of course override existing templates. This is where the priority property in configuration takes its sense.

Built-in XSL templates have 0 as priority


Consider the following example to switch from usage of <b> to <strong>: