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
By convention, your block must be named
|The field to display|
|The ContentInfo to which the field belongs to|
|The VersionInfo to which the field belongs to|
|Settings of the field (depends on the FieldType)|
|Options passed to |
|The attributes to add the generate the HTML markup. |
Contains at least a
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
field_attributes blocks provided in content_fields.html.twig.
To be able to reuse built-in blocks, your template must inherit from
Registering your template
To make your template available, you must register it to the system.
You can define these rules in a dedicated file instead of
ezpublish/config/ezpublish.yml. Read the cookbook recipe to learn more about it.