CMS Development

sking1
Contributor

Add an HTML title if a topic contains a certain word (Blog)

SOLVE

I would like to add a title of "Featured Products" if a post contains a topic OR topics that begin with the word "Product." Because some posts have more than one topics containing the word "Product" the title appears that many times.  Below is a visual representation of what is happening.

 

Featured Products

Featured Products

 

Product One Title

Product one description. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

 

Product Two Title

Product two description. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

 

This is the Hubl I used. Using the filters |first or |unique do not work. 

 

{% for topic in content.topic_list %}
{% if topic.name is string_startingwith "Product" %}
{% set string_var = '<h6 class="pb-3">Featured Products' %}
{{ string_var|first }}
{% endif %}
{% endfor %}

 

 

0 Upvotes
1 Accepted solution
sking1
Solution
Contributor

Add an HTML title if a topic contains a certain word (Blog)

SOLVE

I figured it out:

 

{% text "my_title" label='Enter a title', value='<h6 class="pb-3">Featured Products</h6>' %} 

{% for topic in content.topic_list %}
{% if topic.name is string_startingwith "Queue" %}
{% elif topic.name is string_startingwith "Menu" %}
{% elif topic.name is string_startingwith "Audience" %}
{% elif topic.name is string_startingwith "Vertical" %}
{% else %}
{{ my_title.value }}
{% endif %}
{% endfor %}

View solution in original post

0 Upvotes
1 Reply 1
sking1
Solution
Contributor

Add an HTML title if a topic contains a certain word (Blog)

SOLVE

I figured it out:

 

{% text "my_title" label='Enter a title', value='<h6 class="pb-3">Featured Products</h6>' %} 

{% for topic in content.topic_list %}
{% if topic.name is string_startingwith "Queue" %}
{% elif topic.name is string_startingwith "Menu" %}
{% elif topic.name is string_startingwith "Audience" %}
{% elif topic.name is string_startingwith "Vertical" %}
{% else %}
{{ my_title.value }}
{% endif %}
{% endfor %}
0 Upvotes