carolineschnapp
5/31/2013 - 6:23 PM

Minimal drop-downs that work with non-English characters.

Minimal drop-downs that work with non-English characters.

<!-- snippets/dropdown.liquid -->

{% if settings.navigation_alignment == "right" %}
<ul class="horizontal fr unstyled clearfix">
{% endif %}
{% if settings.navigation_alignment == "below" %}
<ul class="horizontal unstyled clearfix">
{% endif %}
  {% 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 %}  
  
  
  {% if has_drop_down == false %}
  <li{% if settings.display_collection_dropdown and link.type == 'collection_link' and link.object.tags.size > 0 %} class="dropdown"{% endif %}{% if settings.display_blog_dropdown and link.type == 'blog_link' and link.object.articles.size > 0 %} class="dropdown"{% endif %}>
    <a href="{{ link.url }}" class="{% if link.active %} current{% endif %}{% if settings.use_cufon_on_navigation %} cufon{% endif %}"><span>{{ link.title }}</span></a>
    {% if settings.display_collection_dropdown and link.type == 'collection_link' and link.object.tags.size > 0 %}
    <ul class="dropdown">
      {% for tag in link.object.tags %}
      <li><a href="{{ link.url }}/{{ tag | handle }}">{{ tag }}</a></li>
      {% endfor %}
    </ul>
    {% endif %}
    {% if settings.display_blog_dropdown and link.type == 'blog_link' and link.object.articles.size > 0 %}
    <ul class="dropdown">
      {% for article in link.object.articles %}
      <li><a href="{{ article.url }}">{{ article.title }}</a></li>
      {% endfor %}
    </ul>
    {% endif %}
  </li>
  {% else %}
  <li class="dropdown"><a href="{{ link.url }}" class="{% if link.active %} current{% endif %}{% if settings.use_cufon_on_navigation %} cufon{% endif %}"><span>{{ link.title }}</span></a>
    <ul class="dropdown">
      {% for l in linklists[child_list_handle].links %}
      <li><a href="{{ l.url }}"{% if l.active %} class="current"{% endif %}>{{ l.title }}</a></li>
      {% endfor %}
    </ul>
  </li>
  {% endif %}
  {% endfor %}
</ul>

<!-- snippets/mobile-menu.liquid -->

{% assign found_active_link = false %}
<select name="main_navigation" id="main_navigation" class="fl">
  {% for link in linklists.main-menu.links %}
    {% if link.active %}
    <option value="{{ link.url }}" selected="selected">{{ link.title }}</option>
    {% assign found_active_link = true %}
    {% else %}
    <option value="{{ link.url }}">{{ link.title }}</option>
    {% endif %}
  
    {% 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 %}  
  
    {% if has_drop_down %}
    {% for childlink in linklists[child_list_handle].links %}
      {% if childlink.active %}
      <option value="{{ childlink.url }}" selected="selected">- {{ childlink.title }}</option>
      {% assign found_active_link = true %}
      {% else %}
      <option value="{{ childlink.url }}">- {{ childlink.title }}</option>
      {% endif %}
    {% endfor %}
    {% endif %}
  {% endfor %}
  {% unless found_active_link %}
  <option value="" selected="selected">{{ page_title }}</option>
  {% endunless %}
  <option value="/cart">Your cart ({{ cart.item_count }})</option>
</select>