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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

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

Started by Bastian 7 years ago · 1 replies · 2464 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, 8 months ago
6 97 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 185 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 148 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 61 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 255 1 year ago