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> 

1 Answer 1

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> 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.