@root collection for main menu


#1

Hi,

I am new to using Grav, but I have used similar CMS’s in the past. I am writing a very simple website for a client. The site has a simple structure:

— Clinic
— Technique
— Process
— Contact
— Detail Pages
—— Details 01
——— Page 01
——— Page 02
—— Details 02
——— Page 01
——— Page 02
—— Details 03
——— Page 01
——— Page 02

In my twig template I would like to create a main menu using just the top level pages, excluding ‘Detail Pages’, when I use this twig code:

{% set main_menu = page.collection({‘items’ : ‘@root.children’}) %}

The var dump, dumps a massive amount of information, however, when I use this code it doesn’t produce any results:

{% for page in main_menu.children.visible %}

{{ page.menu }}

{% endfor %}

I am quite confused as to how to pull different collections using twig in custom websites. I have read through the documentation online, but the majority of the content seems to focus on yaml files. Any help, or useful tutorials would be very welcome.

Thanks