- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Add an HTML title if a topic contains a certain word (Blog)
SOLVENov 28, 2018 5:21 PM - edited Nov 28, 2018 5:23 PM
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 %}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Accepted Solutions
Nov 28, 2018 6:08 PM
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 %}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content