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

Split Navigation Menus for Footer

Started by Will Moody 7 years ago · 4 replies · 676 views
7 years ago

Hello
Just getting to grips with Grav, all good so far but I have an issue with navigation that I cannot find an answer to.
I would like to hide some pages from the main navigation and instead list them in the footer section of each page.
I have found if I use 'visible: false' that the pages don't appear in the main navigation which is perfect.
I can then add them to the footer using this code:-

ul
{% for page in pages.children %}
{% if page.visible ('false') %}
li a href="{{ page.url }}" {{ page.menu }} /a /li
{% endif %}
{% endfor %}
{% for mitem in site.menu %}
li a href="{{ mitem.link }}" {{ mitem.text }} /a /li
{% endfor %}
/ul

(not sure how to add code with the <> in place)

but this also shows the pages that are marked as visible.
How can I exclude the pages marked as visible from this list?
Or is this the wrong way of solving this issues?

7 years ago

Hi @fatbuddhadesigns, this is not tested but this should provide a for loop with only visible pages:

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

I hope the above is helpful.
Paul

7 years ago

Hello Paul

That displays pages that are marked as visible: true , in this particular case I am trying to display pages that are marked as visible: false.
These will give a navigation menu to such pages as my cookies and privacy policy which I don't want to display in the main navigation, but in the footer instead.

Thanks

Will

7 years ago

Hi @fatbuddhadesigns, sorry that I misread your question🙂

try this:

{% if not (page.visible) %}

BTW, to display code here in the forum use three backticks in a row - for example:

TWIG
{% if not (page.visible) %}

Let me know if then above works for you.
Paul

7 years ago

Thanks Paul,
That works a treat.
Will try the code format next time I am here.
Once again, thank you.

👍 1

Suggested topics

Topic Participants Replies Views Activity
General · by Hanns Mattes, 21 hours ago
1 28 13 hours ago
General · by Andy Miller, 14 hours ago
0 25 14 hours ago
General · by Jerry Hunt, 5 days ago
2 145 2 days ago
General · by pamtbaau, 2 days ago
1 96 2 days ago
General · by Andy Miller, 2 days ago
0 81 2 days ago