首先添加这个配置参数
parameters:
ezpublish_legacy.default.module_default_layout: 'YourBundle::pagelayout_legacy.html.twig'
您可以将其添加到位于 的parameters.yml
文件中path/to/yourezpublishinstall/ezpublish/config
,parameters.yml
通常会在config.yml
位于同一文件夹中的文件中导入
这会将位于的 twig 模板定义path/to/yourbundle/Resources/views/pagelayout_legacy.html.twig
为旧堆栈模块模板的父模板
在pagelayout_legacy.html.twig
模板中,您可以使用此代码
{% 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 %}
注意在代码中,模板扩展了pagelayout.html.twig
模板,这里应该定义一个名为 content 的块,pagelayout.html.twig
通常可能是您的 ez publish 5 网站的主要基本布局,您可以根据pagelayout_legacy.html.twig
需要修改模板
参考:
http ://share.ez.no/forums/developer/overriding-legacy-error-pages-templates