Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.7.27.2]: Nav tag doesn't output as expected when parent entry is disabled #10925

Closed
GaryReckard opened this issue Apr 16, 2022 · 2 comments
Closed

Comments

@GaryReckard
Copy link

What happened?

Description

When using the {% nav %} tag, as described here, it seems to be incorrectly assigning the children of a disabled entry to the previously enabled entry.

Steps to reproduce

  1. Have a Structure, and have two root level entries "Parent 1" and "Parent 2", and two child entries "Child 1" and "Child 2" under "Parent 2". All entries are 'Enabled'.
  2. Use the {% nav %} loop referenced above to output those entries in a nested fashion
{% set aboutPages = craft.entries.section('pages').all() %}
{% if aboutPages | length %}
    {% nav page in aboutPages %}
        <li>
            {% if page.parent %}[Parent: {{ page.parent.title }}] {{ page.getLink() }}
            {% ifchildren %}
                <ul>
                    {% children %}
                </ul>
            {% endifchildren %}
        </li>
    {% endnav %}
{% endif %}
  1. That should output
  • Parent 1
  • Parent 2
    • [Parent: Parent 2] Child 1
    • [Parent: Parent 2] Child 2
  1. Now 'Disable' the root entry 'Parent 2'

Expected behavior

I would expect that, since Parent 2 is disabled, it would not show and its children would not either. Something like:

  • Parent 1

And if "Child 1" and "Child 2" were to show, I would think the {{ page.parent.title }} tag would show their actual parent

Actual behavior

However, it seems to output the children of "Parent 2" anyway, and thinks their parent is "Parent 1"

  • Parent 1
    • [Parent: Parent 1] Child 1
    • [Parent: Parent 1] Child 2

Craft CMS version

3.7.27.2

PHP version

7.3.33

Operating system and version

No response

Database type and version

MySQL 5.7.37

Image driver and version

No response

Installed plugins and versions

No response

@brandonkelly
Copy link
Member

I would expect that, since Parent 2 is disabled, it would not show and its children would not either.

Good call. Just fixed this for the next release!

@brandonkelly
Copy link
Member

Just released 3.7.39 with this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants