문제

This is the code for my header 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 | handleize %}
    {% if linklists[child_list_handle].links != blank %}
    <div class="has-dropdown">
      <a href="{{ link.url }}" class="clearfix">
        <span class="nav-label">{{ link.title | escape }}</span>
        <span class="nav-arrow"></span>
      </a>
      <ul>
        {% for childlink in linklists[child_list_handle].links %}
        <li><a href="{{ childlink.url }}">{{ childlink.title | escape }}</a></li>
        {% endfor %}
      </ul>
    </div>
    {% else %}
      <a href="{{ link.url }}">{{ link.title | escape }}</a>
    {% endif %}
  </li>
  {% endfor %}
</ul>

I am not sure what lanugage this is written in but I want to change it so that any item named "featrued" is not shown in the menu. The sudo code would be something like this:

if name!="featured" then {  ...    }...

This is what I tried:

{% if link.title != featured %}
...
{% endif %}

Could anyone please help me understand what adjustment would need to be made?

도움이 되었습니까?

해결책

You're close! You just need to enclose the link's title in quotation marks.

Try this:

<ul>
  {% for link in linklists.main-menu.links %}
    {% if link.title != 'featured' %}
      <li class="{% if forloop.first %}first{% elsif forloop.last %}last{%endif%}">
        ...
      </li>
    {% endif %}
  {% endfor %}
</ul>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top