A
A
agromov912020-08-20 13:21:38
symfony
agromov91, 2020-08-20 13:21:38

Custom 404 page?

In app/Resources/TwigBundle/views/Exception/ created a file error404.html.twig with the following content

{% extends 'base.html.twig' %}

{% block body %}
    <h1>Page not found</h1>
{% endblock %}


As a result, base.html.twig is pulled up, but the entire body is replaced with h1, so there is no header or footer.

If you remove
{% block body %}
    <h1>Page not found</h1>
{% endblock %}


Then the header and footer are loaded, but how can I substitute h1 in the main part?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Novoselov, 2020-08-20
@agromov91

Read the documentation about
parent()
https://twig.symfony.com/doc/3.x/functions/parent.html
try adding it to the block
You can also add additional blocks in the base.html.twig template in the body block, which will reassign

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question