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

How can i use {% include %} to include a template in the /user/pages/

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

hi guys. i have a problem in developing a theme of my site. in the templates /modular/abc.html.twig file I want to use {% include '/user/pages/02.abc/_abc/abc.html.twig' %} to returns the rendered content of .html.twig file in /user/pages/02.abc/_abc/. but it comes up with an error saying “An exception has been thrown during the rendering of a template ("Template "/user/pages/02.abc/_abc/abc.html.twig" is not defined.") in "modular.html.twig" at line 26.” how could i solve this problem.

11 years ago

The page you are on already has been rendered by the time you get to the theme, then it's just a matter of:

TWIG
{{ content }}

If you want to display the content of another modular page it's:

TWIG
{{ page.find(/abc/_abc).content }}

This will render the content (ie, the page with markdown/twig processed). It's wont actually render the Twig which the page would normally use.

If you wanted to render Twig + content you could do something like:

TWIG
{% include 'modular/abc.html.twig' with {'content' : page.find(/abc/_abc).content} %}

Which simply loads a particular modular template and sets the content to be the content from a particular page.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1349 9 years ago
Archive · by Muut Archive, 9 years ago
2 934 9 years ago
Archive · by Muut Archive, 9 years ago
2 4060 9 years ago
Archive · by Muut Archive, 9 years ago
1 2946 9 years ago
Archive · by Muut Archive, 9 years ago
3 1118 9 years ago