1

I have a navigation menu setup but I want to filter out some of the children at level(2) so they aren't showing in the dropdown navigation menu. Here is how I am grabbing the children...

{% set mainEntry = craft.entries.slug(craft.request.getSegment(1)).one() %}
{% set subnav = craft.entries.descendantOf(mainEntry).level(2) %}

<div class="menu">
            <ul class="no-list-style">
                <li><a href="{{mainEntry.getUrl}}">Home</a></li>
                <li><a href="javascript:void(0);">Conference</a><i class="fa fa-chevron-down"></i>
                    <div class="sub-menu">
                        <ul class="no-list-style">
                            {% for page in subnav %}
                            <li>
                                {{ page.link }} 
                            </li>
                            {% endfor %}
                        </ul>
                    </div>
                </li>
             </ul>
          </div>
2
  • Can you add more details on the filtering? Are you just needing to manually pick entries to hide from the nav? Apr 12, 2019 at 19:38
  • Yes, is there a way to pick which child entries I want to hide?
    – user9494
    Apr 13, 2019 at 20:49

1 Answer 1

1

The way I usually accomplish this is to add a "Hide From Nav" Lightswitch field to the sections I want to filter.

This will filter out any entries where the Lightswitch is "on".

{% set subnav = craft.entries.descendantOf(mainEntry).hideFromNav('not 1').level(2) %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.