We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Having trouble with scoping

Kenny Noten October 20, 2020 by Kenny Noten

Hi, so I'm learning Statamic and making my first site.

I have a navigation with a submenu of entries that show the name and short_description(optional) of the entry.

I'm using the nav tag in the template file that looks like this:

{{ nav handle="main_menu" include_home="false" }}
        {{ if children }}
            <span>{{ title }}</span>
            <ul class="sub-menu">
                {{ children }}
                        <a href="{{ url }}">
                            <h1>{{ name }}</h1>
                            <p>{{ short_description }}</p>
                {{ /children }}
        {{ else }}
            <a href="{{ url }}">{{ title }}</a>
        {{ /if}}
{{ /nav }}

This works fine until I'm on a page of an entry that has a short_description. This will fill in all the empty menu items with its short_description.

I have looked in the documentation and tried various things, but can't seem to find the right solution.

Answered by Erin Dalzell!
>>>>>>> Answered <<<<<<<
1 Reply