CMS Development

DM2
メンバー

Excluding multiple blog topics from a topic list

解決

Hi

 

I am showing a list of topics but have 3 that I don't want to show (Novice, Intermediate and Advanced). I've tried this:

 

{% for topic in post.topic_list %}
 {% if topic.name != ['Novice', 'Intermediate', 'Advanced'] %}
  {{ topic.name }} 
 {% endif %}   
{% endfor %}

 

but that returns no topics.

 

Grateful for any help here.

0 いいね!
1件の承認済みベストアンサー
piersg
解決策
キーアドバイザー

Excluding multiple blog topics from a topic list

解決

@DM2 it should work if you do this:

{% for topic in post.topic_list %}
 {% if topic.name is not in ['Novice', 'Intermediate', 'Advanced'] %}
  {{ topic.name }} 
 {% endif %}   
{% endfor %}

 

元の投稿で解決策を見る

2件の返信
DM2
メンバー

Excluding multiple blog topics from a topic list

解決

Brilliant, thanks so much.

0 いいね!
piersg
解決策
キーアドバイザー

Excluding multiple blog topics from a topic list

解決

@DM2 it should work if you do this:

{% for topic in post.topic_list %}
 {% if topic.name is not in ['Novice', 'Intermediate', 'Advanced'] %}
  {{ topic.name }} 
 {% endif %}   
{% endfor %}