General

  eZ Systems Website
  Technical documentation
  Editor documentation

This Documentation contains:
 
Technical documentation:



⚠ WARNING ! This documentation is deprecated !

Please go to the current Technical Documentation

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

ez_render_field() is a Twig helper allowing you to display a Content item's Field value, taking advantage of the template block exposed by the FieldType Field Type used.

Info

Template blocks for built-in FieldTypes Field Types reside in EzPublishCoreBundle.

...

Argument nameTypeDescription
contenteZ\Publish\Core\Repository\Values\Content\ContentContent object the displayable field belongs to.
fieldDefinitionIdentifierstringThe identifier the Field is referenced by.
paramshash

Hash of parameters that will be passed to the template block.

By default you can pass 2 entries:

  • lang (to override the current language, must be a valid locale with xxx-YY format)
  • template (to override the template to use, see below)
  • attr (hash of HTML attributes you want to add to the inner markup)
  • parameters (arbitrary parameters to pass to the template block)
Info
Some FieldTypes Field Types might expect specific entries under the parameters key, like the Map Location field type

...

Info

Your template block must comply to a regular FieldType Field Type template block, as explained in the FieldType Field Type documentation.

Inline override

...

Tip
titleOverriding a block and calling the parent

When overriding a field template block, it is possible to call the "parent." one. For this, you need to import original template horizontally, using use Twig tag.

Code Block
languagexml
{# AcmeTestBundle/Resources/views/fields/my_field_template.html.twig #}
{# Assuming "my_field_identifier" from above template example is an ezkeyword field. #}
 
{% use "EzPublishCoreBundle::content_fields.html.twig" with ezkeyword_field as base_ezkeyword_field %}
 
{# Surround base block with a simple div #}
{% block ezkeyword_field %}
    <div class="ezkeyword">
        {{ block("base_ezkeyword_field") }}
    </div>
{% endblock %}

...

Inline override using current template

Info
titleVersion compatibility

Inline override using current template is possible as of 5.2 / 2013.11

 

If you want to override a specific field template only once (i.e. because your override would be only valid in your current template), you can specify the current template to be the source of the field block.

...

Warning
titleLimitation

Using _self will only work if your current template is extending another one.

This is basically the same limitation than as for Symfony form themes.

 

Global override

...