Global navigation

   Documentation Center
   eZ Studio & eZ Platform
     User Manual
     Technical Manual
   eZ Publish 4.x / legacy

eZ Publish (5.x)

eZ Publish 5.x | For eZ Platform & eZ Studio topics see Technical manual and User manual, for eZ Publish 4.x and Legacy topics see eZ Publish legacy

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Table of Contents

Defining your FieldType template

In order to be used by ez_render_field() Twig helper, you need to define a template containing a block dedicated to the Field display.

This block consists on a piece of template receiving specific variables you can use to make the display vary.


You will find examples with built-in FieldTypes in EzPublishCoreBundle/Resources/views/content_fields.html.twig

Code Block
titleTemplate for a FieldType with "myfieldtype" identifier
{% block myfieldtype_field %}
{# Your code here #}
{% endblock %}

By convention, your block must be named <fieldTypeIdentifier>_field.

Exposed variables

fieldeZ\Publish\API\Repository\Values\Content\FieldThe field to display
contentInfoeZ\Publish\API\Repository\Values\Content\ContentInfoThe ContentInfo to which the field belongs to
versionInfoeZ\Publish\API\Repository\Values\Content\VersionInfoThe VersionInfo to which the field belongs to
fieldSettingsmixedSettings of the field (depends on the FieldType)
parametershashOptions passed to ez_render_field() under the parameters key
attrhashThe attributes to add the generate the HTML markup.
Contains at least a class entry, containing <fieldtypeidentifier>-field

Reusing blocks

To ease FieldType template development, you can take advantage of all defined blocks by using the block() function.

You can for example take advantage of simple_block_field, simple_inline_field or field_attributes blocks provided in content_fields.html.twig.


To be able to reuse built-in blocks, your template must inherit from EzPublishCoreBundle::content_fields.html.twig.

Registering your template



To make your template available, you must register it to the system.

Code Block
                    template: "AcmeTestBundle:fields:my_field_template.html.twig"
                    # Priority is optional (default is 0). The higher it is, the higher your template gets in the list.
                    priority: 10

You can define these rules in a dedicated file instead of ezpublish/config/ezpublish.yml. Read the cookbook recipe to learn more about it.