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

Using child page content in multiple templates

Started by Muut Archive 11 years ago · 4 replies · 373 views
11 years ago

I have a project listing page with a large number of child pages. Each child page has custom headers with that project's info. How can I use that info in other templates besides the project.html.twig template? My goal is to have three random listings in a home page module and an alpabeticaly linked list of some project content on another page.

11 years ago

OK. I also just found this in the documentation:

TWIG
<ul>
{% for p in page.find('/projects').children if p != page %}
<li><a href="{{p.url}}">{{ p.title }}</a></li>
{% endfor %}
</ul>

Does that only list all projects where the method you mentioned llets you apply filters to which ones get shown?

11 years ago

it's basically the same thing, but my example get's a specific page, where as the one you mentioned in the docs gets all the children of a particular page, and loops over them.

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 2938 9 years ago
Archive · by Muut Archive, 9 years ago
3 1111 9 years ago