This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » eZ Publish 5 Platform » How to override legacy templates?

How to override legacy templates?

How to override legacy templates?

Tuesday 12 November 2013 6:41:31 pm - 10 replies


I'm pretty new to eZ Publish so forgive my possible dumb question happy.gif Emoticon

Starting from the ezdemo extension shipped with eZ Publish Community Project 2013.09, I want to upgrade the templates to Bootstrap 3 (ezdemo uses Bootstrap 2). My custom page layout is correctly set up and everything's fine when I override the default Twig templates with my new ones.

But I'm wondering how to override all the Legacy stuff?

For exemple, I'm trying to override the feedback form template located in ezpublish_legacy/extension/ezdemo/override/templates/full/feedback_form.tplCan I override this file in my eZ Publish 5 custom bundle or do I need to override it the eZ Publish 4 way (if so, where?)

Thanks for your help

Wednesday 13 November 2013 11:59:11 am


see here

and here to override/to pass a specific class to an twig template:

here is an example for the class identifier: page_layout

            legacy_mode: false
                        template: YOURBundle::page_layout.html.twig
                            Identifier\ContentType: page_layout

Wednesday 13 November 2013 12:38:47 pm

Thanks for your help Ramzi,

I already have something like this in my bundle template_rules.yml file :

                    template: OremeBootstrapDemoBundle:full:feedback_form.html.twig
                        Identifier\ContentType: [feedback_form]

The template is correctly overridden. But the original feedback form template has a lot of {attribute_view_gui} eztemplate function. I'm not sure how to proceed to change that.

This post from Damien Pobel says that collectible fields are not fully implemented yet (but the post is a bit old now).

I'm wondering if overriding every legacy template from ezdemo is something currently possible?  

Modified on Wednesday 13 November 2013 12:45:15 pm by Julien Huon

Wednesday 13 November 2013 12:52:04 pm


i dont have the new release but you can take a look here which fields are actually implemented.


Just you need the new template functions:

the $node information you can find it in "content"

the attribute_view_gui  is replaced with  ez_render_field()  here some example to get contentInfos from the attribute  identifier:

rendering images:

 {{ ez_render_field( content, 'image', { parameters:{ image_class:'original' } } ) }}

body xml :

 {{ ez_render_field( content, 'body' ) }}

or directly get this infos from the attribute identifier :


or to get image path :

 {{contentElement.getFieldValue('image').path }}


Wednesday 13 November 2013 3:43:41 pm


There's a lot of fieldtypes available in eZ/Bundle/EzPublishCoreBundle/Resources/config/fieldtypes.yml. But how can I use it in a form context?

What about form values? Do you know if there's a "form" variable available, with widgets, à la Symfony? Do I need to write all the markup? 

If the feedback form still rely on legacy code, it seems there is no easy way to override the templates (because of the widgets implementation and errors handling, just to name a few). Is this correct?

Symfony2 form doc:


Wednesday 13 November 2013 5:44:47 pm


Can we use this method to override user/login.tpl ?


Thursday 14 November 2013 2:43:48 pm

Hi Julien,

i have no big experience with getting form attribute from backend in the twig tpl and pass them to the controller to create getter and setter. right now i m using only Symphony Form.

Thursday 14 November 2013 2:49:23 pm

@H.H  : yes you can, you should know that the Symphony route comes in the front of the request, when the route not exist then a fallback to legacy will take place.

you can catch the route in the Symphony route.yml so that when the route is user/login then you should write a controller for it and the Controller will render the correspondant views like login.tpl

Take a look how to create a route in the Symhony stack or see the implementation of the default Controller.

Friday 15 November 2013 10:33:59 am


Collectable fields are AFAIK not yet supported in the new stack, I am afraid you will need to implement/override the old template. 

Friday 15 November 2013 12:01:00 pm


in fieldtypes.yml there are a list of "Not implemented fieldtypes" . If one of them are defined as class attribute, then we can not get the attribute value in the object contentInfo or using getFieldValue().

Friday 15 November 2013 2:45:49 pm


Sure i know that i can catch the route, but in this case i have to rewrite all the code to manage the user login.php and register.php.

I was looking for a way to keep the ezpublish user method, and just override the view in my bundle. Not to rewrite all from scratch...

Anyway i will go on override old template and wait next version to move in a cleaner way


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from