Skip to content

Instantly share code, notes, and snippets.

@carolineschnapp
Created July 17, 2012 15:17
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save carolineschnapp/f95b1e4d0f9401ce6d20 to your computer and use it in GitHub Desktop.
Save carolineschnapp/f95b1e4d0f9401ce6d20 to your computer and use it in GitHub Desktop.
Dropdown menus that handle Japanese / Chinese
<nav role="navigation">
<ul id="nav">
{% for link in linklists.main-menu.links %}
{% assign has_drop_down = false %}
{% assign child_list_handle = link.title | handle %}
{% comment %}If the link uses the arabic, hebrew or cyrillic alphabet, or is in Chinese or Japanese, the handle will be empty.{% endcomment %}
{% if child_list_handle == '' %}
{% for i in (0..8) %}
{% unless has_drop_down %}
{% if forloop.first %}
{% assign temp = 'link-list' %}
{% else %}
{% capture temp %}link-list-{{ i }}{% endcapture %}
{% endif %}
{% if linklists[temp] and linklists[temp].links.size > 0 and linklists[temp].title == link.title %}
{% assign has_drop_down = true %}
{% assign child_list_handle = temp %}
{% endif %}
{% endunless %}
{% endfor %}
{% else %}
{% if linklists[child_list_handle] and linklists[child_list_handle].links.size > 0 %}
{% assign has_drop_down = true %}
{% endif %}
{% endif %}
<li class="nav-item{% if forloop.first %} first{% elsif forloop.last %} last{% endif %}{% if link.active %} active{% endif %}{% if has_drop_down %} dropdown{% endif %}">
<a class="nav-item-link smooth" href="{{ link.url }}">
{{ link.title }}
</a>
{% if has_drop_down %}
<ul class="sub-nav">
<li class="sub-nav-niblet"></li>
{% for l in linklists[child_list_handle].links %}
<li class="sub-nav-item{% if forloop.first %} first{% elsif forloop.last %} last{% endif %}">
<a class="sub-nav-item-link {% if forloop.first %}first{% endif %} {% if forloop.last %}last{% endif %}" href="{{ l.url }}">{{ l.title }}</a>
</li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
</nav>
@saibm
Copy link

saibm commented May 8, 2015

I am not a professional programmer. Can you help where should put this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment