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

Theme inheritance : extend parent template

Started by Muut Archive 9 years ago · 2 replies · 1069 views
9 years ago

Hi,

I use theme inheritance (parent theme is antimatter) as described here : https://learn.getgrav.org/themes/customization#theme-markinheritance/mark . I just want to change the content of header block in templates/partials/base.html.twig. I try to do this without copying the entire base.html.twig file.
Instead, I want to extend antimatter's base.html.twig and just modify header block content. I naively try this (in templates/partials/base.html.twig in my new theme) :

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

{% block header %}
    new header content here
{% endblock %}

Of course, this does'nt work. Grav extends base.html.twig in new theme (over and over again until php crashes) and not in antimatter. I also tried ../../antimatter/templates/partials/base.html.twig without success.

Is there any way to reference antimatter file (which has the same name) in extends tag ?

9 years ago

No this is not going to work as it's an endless loop.

You could alter the page templates (default.html.twig..) to reference a yourbase.html.twig which in turns extends base.html.twig, but this is just more work than simply replacing the base template, probably.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1333 9 years ago
Archive · by Muut Archive, 9 years ago
2 924 9 years ago
Archive · by Muut Archive, 9 years ago
2 4055 9 years ago
Archive · by Muut Archive, 9 years ago
1 2933 9 years ago
Archive · by Muut Archive, 9 years ago
3 1110 9 years ago