Skip to content
● Grav 2.2 is out: 2x faster cold starts and 96% less memory on big sites. Read the announcement →

Get all childs of parent page in one twig template of parent's child

Started by Bastian 7 years ago · 1 replies · 2743 views
7 years ago

Hello,

I have generally no idea how I can get child pages from one child page under the same parent page via twig?

For example I have a box page inside another page. And for example I want to get information from other boxes in this page and want to display it in that box.

I know there is a way with the find function where I have to put in the exact path, but I'm looking for a general solution without any direct path. Therefore I want to get the parent of this child and then a collection of all childes of this parent.

How can I do that in twig?

Thanks a lot!

7 years ago

Hi @Red77, if I am following correctly you want a method to get the children of a parent page which is a child? I've done a page collection of getting the children of a parent page in my bootstrap4 open matter theme for "Sections" type pages (https://demo.hibbittsdesign.org/grav-open-matter-course-hub/multi-section-page), which might be part of what you are looking for.

https://github.com/hibbitts-design/grav-theme-bootstrap4-open-matter/blob/master/templates/sections.html.twig#L120

Here is the docs about page collections:
https://learn.getgrav.org/16/content/collections

Hope the above is of help.
Paul

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 11 months ago
6 1200 11 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 964 1 year ago
Content & Markdown · by Jan L'Am, 2 years ago
4 844 2 years ago
Content & Markdown · by Leonardo, 2 years ago
3 766 2 years ago
Content & Markdown · by belthasar, 2 years ago
4 1180 2 years ago