CMS Development

Amit_95
Participant | Platinum Partner
Participant | Platinum Partner

Get tags from blog and assign them a variable

Lets say I have ten blog tags. I want to:

  1. Get the tag associated to each blog
  2. Assign the tags to a variable

I want to do this because I want to filter which blogs are displayed. For example, if I have `Company`, `Interviews` and `Vlogs` as tags, I'm planning to get the tags, and set its value to something else.

 

<div class="all

  {% for tag in content.tag_list %}

  {% if tag == "Company" %}
    {% set company_tag == 'company' %}

     {% elif tag == "News" %}
      {% set news_tag == 'news' %}

     {% elif tag == "Interviews" %}
        {% set reviews_tag == "interviews" %}
        
     {% elif tag == "Tech" %}
        {% set tech_tag == "tech" %}
        
     {% elif tag == "Vlog" %}
        {% set tech_tag == "vlog" %}                  
        
  {% endif %}
                  
                  
  {{ company_tag }} {{ humidity_tag }} {{ air_tag }} {{ news_tag }} {{ reviews_tag }} {{ radon_tag }} {{ tech_tag }}

  {% endfor %}

">

 

So if `blog test` has the tags "Interviews" and "Vlogs", it will add the classes `interviews` and `vlog` to the div.

 

Any clean way of doing this?

 

0 Upvotes
1 Reply 1
jennysowyrda
Community Manager
Community Manager

Get tags from blog and assign them a variable

Hi @Amit_95,

 

I wanted to share this resource as a starting point which can assist with your end goal.

 

Thank you,
Jenny

0 Upvotes