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

@root collection for main menu

Started by Keith 8 years ago · 0 replies · 690 views
8 years ago

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 %}
<a href="{{ page.url }}">
{{ page.menu }}
</a>
{% 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

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 99 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 186 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 62 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 257 1 year ago