ez_render_field() is a Twig helper allowing to display a Content's Field value, taking advantage of the template block exposed by the FieldType used.
Template blocks for built-in FieldTypes reside in EzPublishCoreBundle.
Prototype and Arguments
ez_render_field( eZ\Publish\Core\Repository\Values\Content\Content content, string fieldDefinitionIdentifier[, hash params] )
|Content object the displayable field belongs to.|
|The identifier the Field is referenced by.|
Hash of parameters that will be passed to the template block.
By default you can pass 2 entries:
Some FieldTypes might expect specific entries under the
Override a template block
In some cases, you may not want to use the built-in template block as it might not fit your markup needs. In this case, you can choose to override the template block to use by specifying your own template. You can do this inline when calling
ez_render_field(), or globally by prepending a field template to use by the helper.
Your template block must comply to a regular FieldType template block, as explained in the FieldType documentation.
You can easily use the template you need by filling the
template entry in the
The code above will load
my_field_template.html.twig located in
In the case where you want to systematically reuse a field template instead of the default one, you can append it to the field templates list to use by
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.