另附:Using non-English characters in drop-down menus非英语如何创建下拉目录。
If your Theme is "Translation-ready", you should follow the simplified translation process instead. How do I know if my Theme is "Translation-ready?"如果你的主题包含有翻译模块,你应该查看simplified translation process(译为简化翻译过程,有需要再翻译此篇,地址
http://docs.shopify.com/manual/your-website/themes/translate-theme)而不是How do I know if my Theme is "Translation-ready?"(怎样确定我的主题有否翻译模块,地址
http://docs.shopify.com/manual/configuration/store-customization/currencies-and-translations/translations/is-my-store-translation-ready)。
If the name of your linklist uses the Arabic, Hebrew or Cyrillic alphabet, or is in Chinese or Japanese, your Shopify theme might be unable to find your drop-down menu.如果你的链接目录使用语言是阿拉伯语,希伯来语,西里尔字母,中文或日语,shopify主题可能无法识别你创建的下拉菜单。
Use this liquid code for your main navigation (either intheme.liquid or called from it using an include statement):在主目录导航上使用下面的liquid code。(也可用在theme.liquid或在include指令下进行释放。)
role="navigation">
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 == '' %} {% fori 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 andlinklists[temp].title == link.title %} {% assign has_drop_down = true %} {% assignchild_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 %}
class="nav-item{% if forloop.first %} first{% elsif forloop.last %} last{% endif%}{% if link.active %} active{% endif %}{% if has_drop_down %} dropdown{% endif%}"> class="nav-item-link smooth" href="{{ link.url }}"> {{ link.title }} {% ifhas_drop_down %}
class="sub-nav">
class="sub-nav-niblet">
{% for l in linklists[child_list_handle].links %}
class="sub-nav-item{% if forloop.first %} first{% elsif forloop.last %} last{%endif %}"> class="sub-nav-item-link {% if forloop.first %}first{% endif %} {%if forloop.last %}last{% endif %}" href="{{ l.url }}">{{ l.title }}
{% endfor %}
{% endif %}
{% endfor %}
在这里查看完整代码:
https://gist.github.com/f95b1e4d0f9401ce6d20The part of the code that locates a drop-down menu is定位下拉目录的代码:
{% 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 %}
The key pieces of information in the above code are:以上代码的关键信息在
has_drop_down, a boolean
child_list_handle, the handle of the drop-down menu