Pregunta

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?

¿Fue útil?

Solución

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>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top