How do I hide children of a disabled parent in a nav? So I've got a {% nav %} I'm trying to create with the following code:

{% nav page in craft.entries.section('pages') %}
    &lt;li&gt;
        &lt;a href="{{ page.url }}"&gt;{{ page.title }}&lt;/a&gt;

        {% ifchildren %}
            &lt;ul&gt;{% children %}&lt;/ul&gt;
        {% endifchildren %}

    &lt;/li&gt;
{% endnav %}


My issue is that I've got a top-level page that has been disabled but has some enabled child/sub pages (second-level). So the code above doesn't display the disabled top-level page but it is showing all the enabled children of that disabled page. I've tried wrapping different parts of the {% nav %} code with a conditional but that seems to interfere with the {% ifchildren %} tag.

So my question is, is this the default Craft functionality? If so, what's the best way to solve this problem? Thanks!
This is an example of our "quick and dirty" menu macro we used in older projects. It's recursive so it can have as many levels as you want and will only fetch enabled entries. For mobile devices the parent entry is rendered in the "child" menu as well because otherwise you won't be able to access parent entries with children.

It looks a bit overwhelming at first, because we had many things to consider but it's relative easy 

&lt;!--
menuCategory: [mainmenu/footermenu/topmenu/descendants]
currentPage: the current entry of the loop
includeStartPage: bool if the start page should be included to the menu
level: current level, integer
parent: parent entry if there is one
original: the original current entry from craft
showParentPage: if the parent page should appear in current menu level for mobile devices
--&gt;
{% macro menu(menuCategory, currentPage, includeStartpage, level = 1, parent = null, original = null, showParentPage = null) %}
    {% set originalPage = (original)? original : currentPage %}
    {% set activeClass = '' %}
    {% if original is not null and currentPage is not null and original.parent is not null %}
        {% if original.parent.id == currentPage.id %}
            {% set activeClass = "active" %}
        {% endif %}
    {% endif %}

    &lt;ul class="{{ activeClass }} {% if parent == null %}clearfix{% endif %}" data-level="{{ level }}"&gt;
        {% if includeStartpage %}
            {% set startseite = craft.entries.section('homepage').first() %}
            &lt;li {% if currentPage.id == startseite.id %}class="active" {% endif %}&gt;
                &lt;a  href="{{ startseite.url }}" title="{{ startseite.title }}"&gt;{{ startseite.title|raw }}&lt;/a&gt;
            &lt;/li&gt;
        {% endif %}

        {% if showParentPage and parent%}
            &lt;li&gt;
                &lt;a  href="{{ parent.url }}" title="{{ parent.title }}"&gt;{{ parent.title|raw }}&lt;/a&gt;
            &lt;/li&gt;
        {% endif %}

        &lt;!-- you can leave that actually these are just the function to fetch the different entries
        for the different menu types
        if you have only one type just do set entries = craft.entries.section('pages').find()
        --&gt;
        {% switch menuCategory %}
            {% case 'mainmenu' %}
                {% set entries = craft.entries.section('pages') %}
            {% case 'topmenu' %}
                {% set entries = craft.entries.section('pages').showInHeaderMenu('1') %}
            {% case 'footermenu' %}
                {% set entries = craft.entries.section('pages').showInFooterMenu('not 0') %}
            {% case 'descendants' %}
                {% set entries = parent.getChildren() %}
        {% endswitch %}

        {% for page in entries %}
            &lt;!-- macro to get the different urls for different entries...
            we have sometimes links to external pages so you could use page.getUrl() as well --&gt;
            {% set url = _self.getUrl(page) %}
            {% set target = _self.getTarget(page) %}
            {% set title = page.title %}
            {% set class = "" %}

            {% switch page.type.handle %}
                {% case 'internalLink' %}
                    {% set title = page.linkName %}
                {% case 'externalLink' %}
                    {% set title = page.linkName %}
                {% default %}
            {% endswitch %}

            {% if (originalPage.getUrl == url|trim and not page.hasDescendants)  %}
                {% set class = "active" %}
            {% endif %}


            {# Check if entry has descendants #}
            {% if not page.hasDescendants or (menuCategory == "footermenu" or menuCategory == "topmenu") %}
                {# List navigation item if entry has NO child entries #}
                &lt;li class="{{ class }}"&gt;
                    &lt;a href="{{ url|trim }}" title="{{ title }}" {{ target }}&gt;{{ title|raw }}&lt;/a&gt;
                &lt;/li&gt;

            {% elseif menuCategory == "mainmenu" or menuCategory == "descendants" %}
                {# List navigation item if entry does have children #}
                &lt;li&gt;
                    &lt;a href="#" class="{{ class }}" title="{{ title }}"&gt;{{ title|raw }}&lt;/a&gt;
                    {% set includeParent = (page.type.handle != 'pageWithoutContent')? true : false %}
                    {{ _self.menu('descendants', page, false, level+1, page, originalPage, includeParent ) }}
                &lt;/li&gt;
            {% endif %}
        {% endfor %}
    &lt;/ul&gt;
{% endmacro %}


Edit

You can use it with

{% import '_macros/menu.twig' as menu %}
&lt;nav id="mainmenu" class="inline"&gt;
    {{ menu.menu('mainmenu', entry, true) }}
&lt;/nav&gt;


You can remove all the entry.getType().handle checks. We have the entry types pageWithoutContent so they will only appear in the menu as "placeholders" to open sub menus, but if the entry type is a page with content the entry must appear in the sub menu as well to make it clickable for mobile devices. These pages need to have an active when they appear as "parents" but not as "children". You can see a working example of this menu here or here