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

Template header throws exception

Started by Muut Archive 11 years ago · 1 replies · 384 views
11 years ago

I'm building a site using modular pages, and I have come across this problem:

I want to have two modules on the same page use the same template. I read the documentation and came across the "template" header:

http://learn.getgrav.org/content/headers#template

Now, this seems straight forward. I select the template by writing it into the header. Right?

So if I have two different modules, each supposed to use the template "textblock", then I should just put the following into the header of the modules' .md files:

TXT
template: textblock

However, when I do this, Grav throws an exception:

An exception has been thrown during the rendering of a template ("Template "textblock.html.twig" is not defined ().") in "modular.html.twig" at line 4.

And, well. There is a textblock.html.twig in the correct place, and it renders correctly as long as I don't write the template into the header.

Am I missing something? What's wrong?

11 years ago

First, i'm not sure you are understanding the mechanics of modular pages. I strongly suggest you download the onepage skeleton and have a look how that page is built. You will see there is a parent page that mere is the container for multiple child pages. Each of those child pages are in their own folder and are named according to their template.

There are in fact 2 different pages that are features.md files and because they are modular (in _ prefixed folders), they use modular/features.html.twig template by default. There is no need to set the template explicitly.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1336 9 years ago
Archive · by Muut Archive, 9 years ago
2 926 9 years ago
Archive · by Muut Archive, 9 years ago
2 4056 9 years ago
Archive · by Muut Archive, 9 years ago
1 2941 9 years ago
Archive · by Muut Archive, 9 years ago
3 1112 9 years ago