CMS Development

DanBQ
参加者 | Elite Partner
参加者 | Elite Partner

Using if statements to show different content depending on blog tag

解決

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 いいね!
1件の承認済みベストアンサー
解決策
Anonymous
適用対象外

Using if statements to show different content depending on blog tag

解決

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

 

 

 

元の投稿で解決策を見る

2件の返信
解決策
Anonymous
適用対象外

Using if statements to show different content depending on blog tag

解決

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
参加者 | Elite Partner
参加者 | Elite Partner

Using if statements to show different content depending on blog tag

解決

That works perfectly!

 

Thank you

0 いいね!