Message-ID: <1622653044.4314.1485866150237.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_4313_1842974806.1485866150236" ------=_Part_4313_1842974806.1485866150236 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html ez_render_field

ez_render_field

=20 =20

Description

ez_render_field() is a Twig helper allowing to display a Co= ntent'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\Value= s\Content\Content content, string fieldDefinitionI= dentifier[, hash params)<= /code>

Argument name Type Description
content eZ\Publish\Core\Repository\V= alues\Content\Content Content object the displayable field belongs to.=
fieldDefinitionIdentifier string The identifier the Field is refere= nced by.
params hash

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

By default you can pass 2 entries:

  • lang (to override the current language, m= ust 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)
Some FieldTypes might expect specific entries under the=20 parameters key, like=20 ezgmaplocation.

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 prependi= ng a field template to use by the helper.

Your template block must comply to a regular FieldType template block, <= a href=3D"/display/EZP/FieldType+template">as explained in the FieldType do= cumentation.

Inline override

You can easily use the template you need by filling the te= mplate entry in the params argument.

=20
{{ ez_render_field( 
       content, 
       'my_field_identifier',
       { 'template': 'AcmeTestBundle:fields:my_field_template.html.twig' }
   ) }}
=20

The code above will load my_field_template.html.twig locate= d in AcmeTestBundle/Resources/views/fields/.

Global override

In the case where you want to systematically reuse a field template inst= ead of the default one, you can append it to the field templates list to us= e by ez_render_field().

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

ezpublish/config/ezpublish.yml
=20
ezpublish:
    system:
        my_siteaccess:
            field_templates:
                - 
                    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
=20

You can define these rules in a dedicated file instead of ezpublis= h/config/ezpublish.yml. <= /span> Read the cookbook recipe to learn more about i= t.

 

 

------=_Part_4313_1842974806.1485866150236--