CMS Development

DanBQ
Participant | Elite Partner
Participant | Elite Partner

Using if statements to show different content depending on blog tag

SOLVE

Hi,

 

I'm trying to create a blog sidebar that shows different content depending on the blog tag for that post.

 

 

Here's the kind of thing I would like to be working:

 

{% if topic.name =='HubSpot' %}
<h1>Hi I'm HubSpot topic text</h1>
{% endif %}

{% if topic.name =='Inbound' %}
<h1>Hi I'm inbound topic text</h1>
{% endif %}

This is a custom module that I'm trying to use in the blog template.

 

Thanks!

0 Upvotes
1 Accepted solution
Solution
Anonymous
Not applicable

Using if statements to show different content depending on blog tag

SOLVE

This might help:

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

source: https://designers.hubspot.com/docs/tutorials/how-to-check-for-a-particular-topic-on-a-blog-post

 

 

 

View solution in original post

2 Replies 2
Solution
Anonymous
Not applicable

Using if statements to show different content depending on blog tag

SOLVE

This might help:

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

source: https://designers.hubspot.com/docs/tutorials/how-to-check-for-a-particular-topic-on-a-blog-post

 

 

 

DanBQ
Participant | Elite Partner
Participant | Elite Partner

Using if statements to show different content depending on blog tag

SOLVE

That works perfectly!

 

Thank you

0 Upvotes