Division GRAV

I am trying to make my first GRAV CMS site . Now in mine pages-folder

it looks like this:

  • home / default.md
  • about
  • about / seite 1 / default.md
  • about / seite 2 / default.md

Now if I put the following code in my html file, only the main points are shown in the navigation.

<nav class="" role="navigation">        
    <div class="">
        <ol class="">
            {% 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 %}                
        </ol>
    </div>
</nav>

      

Is there a way to show all pages including subpages in the navigation?

thanks for your reply...

+3


source to share


1 answer


This will give you the maximum level of children (subpages) in your navigation:



<nav class="" role="navigation">        
    <div class="">
        <ol class="">
            {% 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>
                    {% if page.children %}
                        <ol class="">
                        {% for child in page.children %}
                            {% if child.visible %}
                                <li class="{{ current_page }}"><a href="{{ child.url }}">{{ child.menu }}</a></li>
                            {% endif %}
                        {% endfor %}
                        </ol>
                    {% endif %}
                {% endif %}
            {% endfor %}                
        </ol>
    </div>
</nav>

      

+3


source







All Articles