CMS Development

dbarbara
Colaborador(a)

Excluding a blog topic from a Topics list

resolver

Hi,

 

I'm using a topic called 'Featured' to display a featured post at the top of the blog listing page and would like to keep the topic 'Featured' from displaying in the topics list.

 

This page has something close. It shows how to check for a particular topic, but doesn't include the markup.

 

 {% if 'Featured' in content.topic_list|map('name') %}
        Markup to print, if the topic "Featured" is set as a post's topic.
    {% endif %}

 Anyone know of some markup I could use to tell the topic 'Featured" NOT print?

 

Thanks!

0 Avaliação positiva
1 Solução aceita
ndwilliams3
Solução
Conselheiro(a) de destaque

Excluding a blog topic from a Topics list

resolver

Are you refering to the post filter that's just the list of topics and post count and links to the topic page? If so, it may be easier to just use CSS to hide it.

 

Find the id of the module, in my case it's hs_cos_wrapper_blog_topic_cloud, and the url of the featured topic page, for example: http://www.example.com/topic/featured. modify the following with your module id and the topic url and add to your stylesheet.

#hs_cos_wrapper_blog_topic_cloud .widget-module ul li a[href="http://www.example.com/topic/featured"] {
display:none;
}

 

Exibir solução no post original

0 Avaliação positiva
9 Respostas 9
anders_grove
Colaborador(a) | Parceiro Elite
Colaborador(a) | Parceiro Elite

Excluding a blog topic from a Topics list

resolver

Best to use HubL for this.

 

Simply exclude the tag from your loop by either using unless or if !=.

 

See example below:

 

{% if content.topic_list %}
  <p id="hubspot-topic_data">
      {% for topic in content.topic_list %}
          {% unless topic.name == "Featured" %}
            <a class="topic-link" href="{{ blog_tag_url(group.id, topic.slug) }}">{{ topic.name }}</a>{% if not loop.last %},{% endif %}
          {% endunless %}
      {% endfor %}
  </p>
{% endif %}
0 Avaliação positiva
benvanlooy
Top colaborador(a) | Parceiro Platinum
Top colaborador(a) | Parceiro Platinum

Excluding a blog topic from a Topics list

resolver

or simply

 

{% if !('Featured' in content.topic_list|map('name')) %}
        Markup to print, if the topic "Featured" is set as a post's topic.
    {% endif %}
cwilbanks
Membro

Excluding a blog topic from a Topics list

resolver

{% unless 'topic goes here' in content.topic_list|map('name') %}

content markup goes here

{% endunless %}

0 Avaliação positiva
ndwilliams3
Solução
Conselheiro(a) de destaque

Excluding a blog topic from a Topics list

resolver

Are you refering to the post filter that's just the list of topics and post count and links to the topic page? If so, it may be easier to just use CSS to hide it.

 

Find the id of the module, in my case it's hs_cos_wrapper_blog_topic_cloud, and the url of the featured topic page, for example: http://www.example.com/topic/featured. modify the following with your module id and the topic url and add to your stylesheet.

#hs_cos_wrapper_blog_topic_cloud .widget-module ul li a[href="http://www.example.com/topic/featured"] {
display:none;
}

 

0 Avaliação positiva
dbarbara
Colaborador(a)

Excluding a blog topic from a Topics list

resolver

Great idea! Thanks!

0 Avaliação positiva
eparker
Participante

Excluding a blog topic from a Topics list

resolver

A simple hubl solution that works, just add the following to your anchor tag:

 

{% if topic.name == 'featured' %}style="display: none;"{% endif %}

 

There is no need for:

 {% if 'Featured' in content.topic_list|map('name') %}
 
 
0 Avaliação positiva
Jsum
Conselheiro(a) de destaque

Excluding a blog topic from a Topics list

resolver

@dbarbara it's the same login as in that page in reverse,

 

 {% if 'Featured' in content.topic_list|map('name') %}
        Markup to print, if the topic "Featured" is set as a post's topic.
    {% endif %}

 does something if the condition is true

 {% unless 'Featured' in content.topic_list|map('name') %}
        Markup to print, if the topic "Featured" is set as a post's topic.
    {% endunless %}

does something if the condition is not true. 

 

Place an "unless" statement inside of your {% for content in contents %} statement that checks for the topic inside of the content.topic_list and it shouldn't display the post if it has the "featured" topic assigned to it. You should be aware though that it will not show ANY posts containing the "featured" topic. 

0 Avaliação positiva
dbarbara
Colaborador(a)

Excluding a blog topic from a Topics list

resolver

Am just trying to hide the Featured topic in the Topics List module, not the actual posts.

 

So I need to hide the "Featured" topic somewhere in here:

 

<div class="span12 widget-span widget-type-raw_jinja blog-topics" style="" data-widget-type="raw_jinja" data-x="0" data-w="12">
{% set my_topics = blog_topics('default', 😎 %}

<ul>
<li class="tab-all" class="active">
<a href="{{ group.absolute_url }}">All</a></li>
{% for item in my_topics %}
<li><a href="{{ group.absolute_url }}/topic/{{item.slug}}">{{ item }}</a></li>
{% endfor %}
</ul>
</div><!--end widget-span --> 

And also here:

<div class="span12 widget-span widget-type-raw_jinja blog-topics-buttons" style="" data-widget-type="raw_jinja" data-x="0" data-w="12">
{% set my_topics = blog_topics('default', 😎 %}
<h3 style="text-align:center; margin: 0">Search By Topic</h3>
<ul>
{% for item in my_topics %}
<li><a href="{{ group.absolute_url }}/topic/{{item.slug}}">{{ item }}</a></li>
{% endfor %}
</ul></div><!--end widget-span 

 

0 Avaliação positiva
Jsum
Conselheiro(a) de destaque

Excluding a blog topic from a Topics list

resolver

This should work:

{% for content in contents %}
    {% for topic in content.topic_list %}
        {% unless 'Featured' in content.topic_list|map('name') %}
        
              <span class="topic-link">{{ topic.name }}</span>

        {% endunless %}
    {% endfor %}
{% endfor %}

In your listing markup you should be looping through the topics of each blog to display the topics per blog on the listing page. Use this unless condition inside that loop and it should omit the "featured" topic.

0 Avaliação positiva