Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Two Horizontal dropdowns only at Top of Page

Started by David Douglass 4 years ago · 1 replies · 589 views
4 years ago

This is a newby question, so please bear with me. In the navigation template (I think) exists this code:

TWIG
<div class = "navbar-collapse collapse">
   <ul class = "nav navbar-nav navbar-right">
      {% for page in pages.children %}
      {% if page.visible %}
      {% set current_page = (page.active or page.activeChild) ? 'active' : '' %}
      <li class = "{{ current_page }}"><a href = "{{ page.url }}">{{ page.menu }}</a></li>
      {% endif %}
      {% endfor %}
   </ul>
</div>

This, from my understanding, creates the drop down menu at the top of the page (correct me if I'm wrong). I suppose that if I continue creating new pages, they will continue creating new dropdown menus across the top of the page. But what I want is only two dropdown menu categories at the top. The other categories and menu items I plan on putting in a sidebar vertically.

How do I get it to only create the first two categories and then stop?

last edited 12/27/22 by David Douglass
4 years ago

@dpdoug,

This, from my understanding, creates the drop down menu at the top of the page (correct me if I’m wrong).

No it doesn't create dropdown menu-items. It creates a menu containing only visible top-level pages. For creating dropdown items, it would need to loop through each page's children.

Note the highlighted "visible" and have a look at the docs on Visible

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Anna, 2 days ago
2 53 16 hours ago
Forms & Blueprints · by Anna, 3 days ago
7 82 16 hours ago
Forms & Blueprints · by Anna, 1 week ago
5 186 6 days ago
Forms & Blueprints · by TomW, 1 month ago
3 379 1 month ago
Forms & Blueprints · by Japhy, 2 months ago
2 595 2 months ago