0

On my eZ publish 5 site I have all my templates in Twig, in the vendor/ezsystems/demobundle/EzSystems/DemoBundle/Resources/views/ subfolders. They are all being used throughout my whole site, no problems there. With one exception: 404 pages. If I go to mysite/nonexistingurl, it gives me a kernel (20) / Error page, with status 404. The template being used for this is the 20.tpl somewhere in eZ publish/symfony, I don't want that, I want to use my own Twig template for this.

How can I achieve this? I added a vendor/ezsystems/demobundle/EzSystems/DemoBundle/Resources/views/Exception/error.html.twig page, but this one is not being called

Danny Hobo
  • 574
  • 1
  • 5
  • 24

1 Answers1

0

first add this configuration parameter

parameters:
    ezpublish_legacy.default.module_default_layout: 'YourBundle::pagelayout_legacy.html.twig'

you may add it in the parameters.yml file located in path/to/yourezpublishinstall/ezpublish/config, the parameters.yml is usually imported in the config.yml located in the same folder

this would define the twig template located in path/to/yourbundle/Resources/views/pagelayout_legacy.html.twig as the parent template for legacy stack modules templates

inside the pagelayout_legacy.html.twig template, you may use this code

{% extends 'YourBundle::pagelayout.html.twig' %}
{% block content %}
    {# module_result variable is received from the legacy controller. #}
    {% if  module_result.errorCode is defined %}
        <h1>{{ module_result.errorMessage }} ({{ module_result.errorCode }})</h1>
    {% else %}
        {{ module_result.content|raw }}
    {% endif %}
{% endblock %}

note in the code, the template extends the pagelayout.html.twig template, that should here define a block named content, the pagelayout.html.twig may usually be the main base layout for your ez publish 5 website you may modify the pagelayout_legacy.html.twig template to your needs

reference: http://share.ez.no/forums/developer/overriding-legacy-error-pages-templates