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.
Archive
Sounds like your looking for the page inject plugin: https://github.com/getgrav/grav-plugin-page-inject
You can also do this more programmatically with Twig:
TWIG
{% set other_page = page.find('/my-other-page') %}
<div id="other-page">
{{ other_page.content }}
</div>
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?
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.
OK, thanks! Good to know.
Log in to reply.
Suggested topics
| Topic | Participants | Replies | Views | Activity |
|---|---|---|---|---|
| 0 | 1333 | 9 years ago | ||
| 2 | 924 | 9 years ago | ||
| 2 | 4055 | 9 years ago | ||
| 1 | 2938 | 9 years ago | ||
| 3 | 1111 | 9 years ago |