Skip to content

Instantly share code, notes, and snippets.

@Chrisedmo
Created July 31, 2012 11:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Chrisedmo/3216293 to your computer and use it in GitHub Desktop.
Save Chrisedmo/3216293 to your computer and use it in GitHub Desktop.
Shopify: 2 Level Dropdown Menu
<ul>
{% for link in linklists.main-menu.links %}
<li class="{% if forloop.first %}first{% elsif forloop.last %}last{%endif%}">
{% assign child_list_handle = link.title | handle %}
{% if linklists[child_list_handle].links != blank %}
<div class="has-dropdown">
<a href="{{ link.url }}" class="clearfix">
<span class="nav-label">{{ link.title }}</span>
<span class="nav-arrow"></span>
</a>
<ul>
{% for childlink in linklists[child_list_handle].links %}
<li class="{% if forloop.first %}first{% elsif forloop.last %}last{%endif%}">
{% assign grand_child_list_handle = childlink.title | handle %}
{% if linklists[grand_child_list_handle].links != blank %}
<div class="has-dropdown">
<a href="{{ childlink.url }}" class="clearfix">
<span class="nav-label">{{ childlink.title }}</span>
<span class="nav-arrow"></span>
</a>
<ul>
{% for grandchildlink in linklists[grand_child_list_handle].links %}
<li class="{% if forloop.first %}first{% elsif forloop.last %}last{%endif%}">
<a href="{{ grandchildlink.url }}">{{ grandchildlink.title }}</a>
</li>
{% endfor %}
</ul>
</div><!-- HAS DROPDOWN 2 -->
{% else %}
<a href="{{ childlink.url }}">{{ childlink.title }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
</div><!-- HAS DROPDOWN 1 -->
{% else %}
<a href="{{ link.url }}">{{ link.title }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment