statamic / v2-hub

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

Can't pass a scoped variable in Nav recursive children #2437

Open mattgossman opened 5 years ago

mattgossman commented 5 years ago

Describe the bug When attempting to use the {{ *recursive children:my_scoped_variable* }} tag in my Nav, the page just renders the text {{ recursive children:my_scoped_variable }} in all of the submenus.

To Reproduce I'm building a navigation that uses the default title for the majority of the navigation links. Some page titles are too long for the navigation so I created an optional field navigation_title. I've been unable to scope the top level menus and child menus successfully.

<ul>
{{ nav from="/" max_depth="2" }}
     <li>
          <a href="{{ url }}">{{ navigation_title or title }}</a>
               {{ if children }}
                    <ul>{{ *recursive children* }}</ul>
               {{ /if }}
          </li>
{{ /nav }}
</ul>

This renders correctly until visiting a page that has the navigation_title tag. All pages that don't have a navigation_title are rendered with the current page's navigation_title tag.

If I scope with post:navigation_title, only the top level navigation is properly renamed, but child level pages aren't. Attempting to use {{ recursive children:navigation_title }} results in the system generating <ul>{{ *recursive children:navigation_title* }}</ul>

Expected behavior The ability to properly scope the navigation regardless of the page the navigation is being rendered on.

Environment details (please complete the following information):