Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Error.html.twig in new theme

Started by Muut Archive 10 years ago · 2 replies · 436 views
10 years ago

Hello,

I followed the tutoriel to create a personalized theme and I meet a problem with the page error. I have no contents for the moment, Antimatter theme show "Error 404 Woops. Looks like this page doesn't exist." All is well :)

I copied the file user/themes/antimatter/templates/error.html.twig in the directory user/themes/mypersonaltheme/templates/error.html.twig. Once the new theme was activated, I have the header which displays but not the contents of the file error.html.twig.

Somebody has an idea?

10 years ago

If you look at the content of the error.html.twig file from the Antimatter theme it looks like this:

TWIG
{% extends 'partials/base.html.twig' %}

{% block content %}
    <div id="error">
        <div>
            <h1>Error {{ page.header.http_response_code }}</h1>
            <p>
                {{ page.content }}
            </p>
        </div>
    </div>
{% endblock %}

As you can see it extends a partials/base.html.twig file, and then it overrides the content block. If your mypersonaltheme doesn't define this content block, then nothing will display.

So just make sure you have a content block definition like in Antimatter:

TWIG
<section id="body" class="{{ class }}">
        {% block content %},{% endblock %} 
</section>

The {% block content%},{% endblock %} will be replaced by the code in your error.html.twig.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1360 9 years ago
Archive · by Muut Archive, 9 years ago
2 939 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2958 9 years ago
Archive · by Muut Archive, 9 years ago
3 1122 9 years ago