2017-01-01 47 views
0

排除某个类别,我试图重建一个侧边栏部件,显示在杰基尔用我的类别。它现在正常工作。我想更改液体模板以排除在此窗口小部件中显示的特定类别链接。杰奇 - 液体模板 - 从微件

{% assign cat_list = site.categories %} 
    {% if cat_list.first[0] == null %} 
    {% for category in cat_list %} 
     <li><a href="{{ site.baseurl }}/categories#{{ category }}">{{ category }} <span class="cat-count">{{ cat_list[category].size }}</span></a></li> 
    {% endfor %} 
    {% else %} 
    {% for category in cat_list %} 
     <li><a href="{{ site.baseurl }}/categories#{{ category[0] }}">{{ category[0] }} <span class="cat-count">{{ category[1].size }}</span></a></li> 
    {% endfor %} 
    {% endif %} 
{% assign cat_list = nil %} 

我想我要的是像

{% for category in cat_list **UNLESS category = 'CATEGORY'** %} 

但没有奏效。我有点卡住了,这可能吗?

谢谢。

回答

0

不显示类别阵列:

{% assign noDisplay = "one,two,three" | split: "," %} => [ “一”, “二”, “三”]

测试:

{% unless noDisplay contains category[0] %} 
{{ category[0] }}... 
{% endunless %} 
+0

谢谢你,我是在一般的液体/编程方式太新,完全理解我将如何实现这在我目前的代码中。但是我现在会采取一个措施,并在我确定有效的时候回来。 –

0

谢谢,@大卫Jacquel

{% assign noDisplay = "CATEGORY" | split: "," %} 
{% assign cat_list = site.categories %} 
    {% if cat_list.first[0] == null %} 
    {% for category in cat_list %} 
     <li><a href="{{ site.baseurl }}/categories#{{ category }}">{{ category }} <span class="cat-count">{{ cat_list[category].size }}</span></a></li> 
    {% endfor %} 
    {% else %} 
    {% for category in cat_list %} 
    {% unless noDisplay contains category[0] %} 
     <li><a href="{{ site.baseurl }}/categories#{{ category[0] }}">{{ category[0] }} <span class="cat-count">{{ category[1].size }}</span></a></li> 
     {% endunless %} 
    {% endfor %} 
    {% endif %} 
{% assign cat_list = nil %}