Glad that's working for you. I think if you wanted to, you could simplify your code a bit. You could just write a reverse of the condition and then skip your else statement. In HubL we can get the inverse of an expression with the "not" or "!" operators. So either of these I think would do the trick for you:
{% set my_topics = blog_topics('default', 250) %}
{% for my_topic in my_topics %}
{% if !(my_topic.name == "Digital Transformation" || my_topic.name == "Retail" || my_topic.name == "Fleet Services") %}
{{my_topic.name}}
{% endif %}
{% endfor %}
or:
{% set my_topics = blog_topics('default', 250) %}
{% for my_topic in my_topics %}
{% if not (my_topic.name == "Digital Transformation" || my_topic.name == "Retail" || my_topic.name == "Fleet Services") %}
{{my_topic.name}}
{% endif %}
{% endfor %}
This way we're looking to see if the topic name is any of "Digital Transformation", or "Retail", or "Fleet Services". Then we're inversing the result. So if the tag is one of those, we'll reverse it so that the condition evaluates to false and that tag doesn't get printed. If the tag isn't one of those selected, we inverse the condition so that it evaluates to true and print the tag.
I don't think it's possible to plug in specific tags to the blog_tags() function. It just takes 2 arguments: the 1st is the blog ID and the 2nd is the number of tags to pull in. But you could run some conditional logic in your loop when you iterate over the tags. So for example something like this:
{% set my_topics = blog_topics('default', 250) %}
{% for my_topic in my_topics %}
{% if my_topic.name == "Topic one" || my_topic.name == "Topic two" || my_topic.name == "Topic three" %}
{# HTML goes here #}
{% endif %}
{% endfor %}
And that way you're only adding the tags into your menu when they're specific tags. Would that work for what you're trying to do?
Glad that's working for you. I think if you wanted to, you could simplify your code a bit. You could just write a reverse of the condition and then skip your else statement. In HubL we can get the inverse of an expression with the "not" or "!" operators. So either of these I think would do the trick for you:
{% set my_topics = blog_topics('default', 250) %}
{% for my_topic in my_topics %}
{% if !(my_topic.name == "Digital Transformation" || my_topic.name == "Retail" || my_topic.name == "Fleet Services") %}
{{my_topic.name}}
{% endif %}
{% endfor %}
or:
{% set my_topics = blog_topics('default', 250) %}
{% for my_topic in my_topics %}
{% if not (my_topic.name == "Digital Transformation" || my_topic.name == "Retail" || my_topic.name == "Fleet Services") %}
{{my_topic.name}}
{% endif %}
{% endfor %}
This way we're looking to see if the topic name is any of "Digital Transformation", or "Retail", or "Fleet Services". Then we're inversing the result. So if the tag is one of those, we'll reverse it so that the condition evaluates to false and that tag doesn't get printed. If the tag isn't one of those selected, we inverse the condition so that it evaluates to true and print the tag.
Hi, @lscanlan - I was wondering if you could take a look at why this isn't working for me when I try to filter out two conditions.
This code is working correctly to filter out any of my topics that contain "Minute":
{% if content.topic_list %}
<div class="post-header-details topic-listing">
<span id="post-topic"><i class="fa fa-tags" aria-hidden="true"></i> {% for topic in content.topic_list %}{% if not topic.name is containing "Minute" %}<a class="post-topic-link topic-seq-{{ loop.index }}" href="{{ group.absolute_url }}/topic/{{ topic.slug }}">{{ topic.name }}</a>{% endif %}{% endfor %}</span>
</div>
{% endif %}
Now I have another topic that I want filtered out named Personal Training. I tried adding it in using the code below, but it's not filtering it out. It does still filter out the topics containing "Minute" though.
{% if content.topic_list %}
<div class="post-header-details topic-listing">
<span id="post-topic"><i class="fa fa-tags" aria-hidden="true"></i> {% for topic in content.topic_list %}{% if not (topic.name is containing "Minute" || topic.name is containing "Personal") %}<a class="post-topic-link topic-seq-{{ loop.index }}" href="{{ group.absolute_url }}/topic/{{ topic.slug }}">{{ topic.name }}</a>{% endif %}{% endfor %}</span>
</div>
{% endif %}