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 » Overriding templates in eZ 5

Overriding templates in eZ 5

Overriding templates in eZ 5

Monday 14 January 2013 8:54:57 pm - 10 replies

What is the best way to override the default page layout on a new eZ5 site? Are new installs required to use the eZDemoBundle as a starting point, and thereby use Symfony & Twig when creating views? Or can we disable the eZDemoBundle somehow and use the legacy template structure?

Monday 14 January 2013 9:36:27 pm

Hi Tyler,

you need to create or change on parameters.yml this:

 ezpublish_legacy.view.default_layout: eZDemoBundle::pagelayout.html.twig



Monday 14 January 2013 10:01:47 pm

Awesome, thanks for the quick reply. Any way to choose an ezpublish_legacy template as the default template, however?

Modified on Monday 14 January 2013 10:35:23 pm by Tyler Harms

Monday 14 January 2013 10:50:34 pm

not directly.. you could call a legacy template from you re fresh pagelayout.html.twig:

 {% ez_legacy_include 'design:test/helloworld.tpl' with {'message': messageForLegacy, 'konamiCode': ['Up', 'Up', 'Down', 'Down', 'Left', 'Right', 'Left', 'Right', 'B', 'A'], 'content': content} %}

But you need to pass all parameters.. so not easy. (you could call LS on controller too)

Modified on Monday 14 January 2013 10:51:07 pm by Philippe Vincent-Royol

Tuesday 15 January 2013 12:37:35 am

Quote from Tyler Harms :

Or can we disable the eZDemoBundle somehow and use the legacy template structure?

I think this can be accomplished with legacy_mode: true, this will make sure the routing goes directly to legacy unless a static route exists. This is done with admin on a clean install.

Modified on Tuesday 15 January 2013 12:38:15 am by André R

Tuesday 15 January 2013 12:03:24 pm

@Tyler: As far i can tell, legacy_mode is set by default. I've upgraded a site from 2012.6 to 2012.11. Following the upgrade stepts i hadn't problems in having it working. 

So, in short, you can upgrade to last version, have the thing working with symfony (you can also have it working without it, or at least i have) and no need to touch anything from the install to have your site up. 

Then, as legacy_mode is enabled, you can still add your overrides to the override.ini.appends.php and work as you used to do. 

Or, what i'm doing now, is changing some parts of the site to have it working with twig and all the power of symfony. happy.gif Emoticon

I recommend to take a look to this post by Damien Pobel

or, even better, take a look at the code he has realeased in github. happy.gif Emoticon. Let me add that it's really helping me in my purpouses.

Friday 25 January 2013 5:40:51 pm

HI @Tyler,

I just went through your question Tyler (through your first thoughts blogpost, congrats for it btw) 

Did you finally find a way to run legacy?

In case you also didn't know, there is a more drastic way to run legacy on eZ5, which consist of directly reaching the legacy environment in the ezpublish_legacy folder. Of course this requires the vhosts to be changed to support legacy way to access the application, and of course this means that you can not play Carlo's game of progressively moving to symfony and twig happy.gif Emoticon this would be only pure legacy. I'll let others comment in case but I just wanted to add this way as one of the potential way to go with eZ5 happy.gif Emoticon


Friday 25 January 2013 5:54:23 pm

@Roland, thanks. I am able to run in legacy mode for most things. I think your approach of pointing apache at my ezpublish_legacy folder is the only way to use a non twig version of the pagelayout, at least as far as I can tell. I, however, am trying my hardest not to rely on the legacy code, instead I am doing what I can to use entirely twig templates. 

So far my biggest challenge with twig templates has been they are not used, for instance when calling an old module/view/param url such as `/tags/view/{tag}`. Those use entirely ez legacy code, seemingly bypassing symfony somehow. I am slowly migrating those to use custom symfony routes, but this is not easy.

Monday 28 January 2013 11:49:39 am

Hi Tyler

For your first question about overriding the base pagelayout by a legacy one, this is not possible directly for now. However it is planned for 5.1 to make eZTemplate a real template engine for Symfony, making possible to use directly the include tag (and not ez_legacy_include) or precise a legacy pagelayout as default fallback pagelayout. Be warned that even with this, you still won't be able to use template inheritance with eZTemplate.

However, as you pointed out, it's not currently possible to render twig templates from legacy templates. Actually this is technically possible but needs a legacy extension to do so. Indeed, Symfony service container is exposed in the legacy kernel as long as you run through Symfony. Thus it's perfectly possible to define an eZTemplate operator/function that calls the templating service and renders a twig template.

Monday 28 January 2013 10:15:49 pm

Quote from Philippe Vincent-Royol :

Hi Philippe;

my parameters.yml looks like this:

ezpublish_legacy.view.default_layout: eZDemoBundle::pagelayout.html.twig

Now i made changes to /myDocumentRoot/src/EzSystems/DemoBundle/Resources/views/pagelayout.html.twig

After clearing the cache i do not see any changes in the source of my site. Do i have a error in reasoning?

Thanks for your support.


Wednesday 06 February 2013 1:23:23 pm

Hi there,

I just installed the eZp5 2012.12 and spent some time to get the "legacy_mode" mode running; this means, that I didn't want to have the twig template from this module:


So, how to proceed to run the legacy:

After installing eZp5 you have to edit the following config file /ezpublish/config/ezpublish.yml: find below "system:" the enty for your siteacces. There are a lot of siteaccesses, so this one could be the right one,  and add "legacy_mode: true":

            legacy_mode: true

Now you have to clear all caches. Change in your <ezp5-root>/ and delete both chaches, for the prod and the dev:

 php ezpublish/console cache:clear --env=dev
php ezpublish/console cache:clear --env=prod

This will delete the cached files in \ezpublish\cache\dev\twig\... and \ezpublish\cache\prod\twig\...

If you reload your page, maybe you will see your website now with the templates from the ezpublish_legacy. If not, then clear the cache in the administration interface.

Since I did the installation of the eZ Demo website (without content), the system is now using the legacy template: /ezpublish_legacy/extension/ezdemo/design/ezdemo/templates/pagelayout.tpl

The apache is pointing with DocumentRoot to this directory: <ezp5-root>/web/

Hope this helps


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

36 542 Users on board!

Forums menu

Proudly Developed with from