1

I'm using the nav tag to build a menu which works great, but i just want to repeat the parent menu item over to any sub nav. So if there is a sub nav, at the top of the sub navs links, i want the parent url repeated once.

My current code is this

 <ul>
   {% nav page in blah %}
    <li>
         {% if page.level == 1 %}
            <a href="/{{ section.handle }}#{{ page.slug }}">{{ page.title }}</a>
                {% else %}
                    {{ page.getLink() }}
         {% endif %}

         {% ifchildren %}
            <ul>
                {% children %}
            </ul>
         {% endifchildren %}
    </li>
    {% endnav %}
 </ul>

and i'm looking at doing something like (but i would love it to work obviously)

 <ul>
   {% nav page in blah %}
    <li>
         {% if page.level == 1 %}
            <a href="/{{ section.handle }}#{{ page.slug }}">{{ page.title }}</a>
                {% else %}
                    {{ page.getLink() }}
         {% endif %}

         {% ifchildren %}
            <ul>
            <li>{{ page.parent.getLink() }}</li> -- this is dodgy
                {% children %}
            </ul>
         {% endifchildren %}
    </li>
    {% endnav %}
 </ul>
2

I'm an idiot, i can just do:

<ul>
   {% nav page in blah %}
    <li>
         {% if page.level == 1 %}
            <a href="/{{ section.handle }}#{{ page.slug }}">{{ page.title }}</a>
                {% else %}
                    {{ page.getLink() }}
         {% endif %}

         {% ifchildren %}
            <ul>
            <li><a href="/{{ page.slug }}">{{ page }}</a></li> -- this is dodgy
                {% children %}
            </ul>
         {% endifchildren %}
    </li>
    {% endnav %}
 </ul>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.