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

FieldType template

=20 =20

Defining your Fi= eldType template

In order to be used by  ez_rende= r_field() Twig helper, you need to define a templ= ate 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=

Template for a FieldType with "myfieldtype" identifier
=20
{% block myfieldtype_field %}
{# Your code here #}
{% endblock %}
=20

By convention, your block must be named <field= TypeIdentifier>_field.

Exposed variables

Name Type Description
field eZ\Publish\API\Repository\Values\Content\F= ield The field to display
contentInfo eZ\Publish\API\Repository\Va= lues\Content\ContentInfo The ContentInfo to which the field= belongs to
versionInfo eZ\Publish\API\Repository\Va= lues\Content\VersionInfo The VersionInfo to which the field= belongs to
fieldSettings mixed Settings of the field (depends on = the FieldType)
parameters hash Options passed to ez_render_= field() under the parameters key
attr hash The 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 de= fined blocks by using the block() function.

You can for example take advantage of simple_block_field, <= code>simple_inline_field or field_attributes blocks pro= vided in content_fields.html.twig.=

Warning

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

Registering your templ= ate

 

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_4321_526833420.1485866174691--