Override template full view in Ezpublish 5 – Symfony/Twig way

Rate this post

The best practice for overriding of EzPublish 5 templates is to use a separate yml file (if you chose yml as a default format) in your bundle.
If you are using eZ Publish 5.1+ / Symfony 2.2+ you can achieve it with help of Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface.

Suppose that you’ve generated your bundle and have something like this in
/src/Ism/EzTestsBundle/DependencyInjection/IsmEzTestsExtension.php


Change it in following way

Now create template_overrides.yml in YourBundle/resources/template_overrides.yml

And finaly YourBundle/Resources/views/full/event.html.twig

Clear all caches, and you should see your brand new overrided template in view full on events.

Some more info:

You can override several object with only one override, i.e Identifier\ContentType: [event, article]

Other types of matchers:

Id\Content – Matches the ID number of the content (old Node Id)
Id\ContentType – Matches the ID number of the content type whose content is an instance of (For example Event’s id is 105)
Id\ContentTypeGroup – Matches the ID number of the group of the content type whose content is an instance of belongs to
Id\Location – Matches the ID number of a location. In the case of a Content, matched against the main location.
Id\ParentContentType – Matches the ID number of the parent content type. In the case of a Content, matched against the main location.
Id\ParentLocation – Matches the ID number of the parent location. In the case of a Content, matched against the main location.
Id\Remote – Matches the remoteId of either content or location, depending on the object matched.
Id\Section – Matches the ID number of the section whose content belongs to
Id\State – Not supported yet.
Identifier\ContentType – Matches the identifier of the content type whose content is an instance of
Identifier\ParentContentType – Matches the identifier of the parent content type. In the case of a Content, matched against the main location.
Identifier\Section – Matches the identifier of the section whose content belongs to
Identifier\State – Not supported yet.
Depth – Matches the depth of the location. The depth of a top level location is 1.
UrlAlias – Matches the virtual URL of the location (i.e. /My/Content-Uri). Important: Matches when the UrlAlias of the location starts with the value passed. Not supported for Content (aka content_view).

Also don’t forget,you can combine several matchers together, i.e.

Ez References:
https://confluence.ez.no/display/EZP/Import+settings+from+a+bundle
https://confluence.ez.no/display/EZP/View+provider+configuration

You may also like...

Lascia un Commento

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *

È possibile utilizzare questi tag ed attributi XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">