statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

[BUG] Unpublished Entries within a Nav Tag are still shown #2504

Open sjclark opened 4 years ago

sjclark commented 4 years ago

Describe the bug When utilising a default Nav Tag with include_entries="true" any entries that are unpublished are still outputted.

To Reproduce Steps to reproduce the behavior:

  1. Make a Nav Tag (with or without recursion) that encompasses entries, and has include_entries="true" eg {{ nav from="/" max_depth="4" include_entries="true" }}
  2. Set one of the entries to Unpublished
  3. See the entry still outputted on the front-end

Expected behavior Unless show_unpublished="true" (which is a boolean defaulted to false) is set then these entries should not be displayed

Environment details (please complete the following information):

Additional context Verified with a couple of users in the Statamic Discord (thanks Rob de Kort).

Is possible to manually workaround by using {{ if is_published }} and replacing the recursion loop in practice (however is still a bug when not utilising recursion):

    {{ nav from="/" max_depth="4" include_entries="true" }}
    <li {{ if is_current }} class="Selected" {{ /if }}>
      <a href="{{ url }}">{{ title }}</a>
      {{ children }}
      <ul>
        {{ if is_published }}
        <li><a href="{{ url }}">{{ title }}</a></li>
        {{ /if }}
      </ul>
      {{ /children }}
    </li>
    {{ /nav }}
sjclark commented 4 years ago

Seems similar in essence to https://github.com/statamic/v2-hub/issues/2497 ?