CMS Development

jc_at_dfuse
Member

How can display a Tag name with is link base on Tag ID

SOLVE

I create a module with on repeatable field base on Tag Selector field. It retrun me a array with tags ID.
I need to display the tag name with tag link base on this ID, how can i do?
tag.filter_tag_name --> return a id like 5751176252

I need the name and the slug

 

 

{% for tag in module.tags_group %}
  <div class="filter-wrapper2">
    <label class="abc-filter">
      <input type="checkbox" id="input-{{ tag.filter_tag_name.slug }}" >
      <span class="label-text">{{ tag.filter_tag_name }}</span>
   </label>
{% endfor %}

 

 

0 Upvotes
1 Accepted solution
piersg
Solution
Key Advisor

How can display a Tag name with is link base on Tag ID

SOLVE

Hi @jc_at_dfuse (thanks for the tag @sharonlicari)

 

You can do this:

{% set all_tags = blog_tags('default', 250) %}
{% for tag in module.tag_field %}
{% for item in all_tags %}
{% if item.slug == tag %}
Name = {{ item }}
Slug = {{ tag }}
Full URL = {{ blog_tag_url(group.id, tag) }}
{% endif %}
{% endfor %}
{% endfor %}

 

But you have to set the value type to return to "Name" instead of "id" in the tag field

Screenshot 2020-07-27 at 10.36.24.png

So for you:

{% set all_tags = blog_tags('default', 250) %}
{% for tag in module.tag_field %}
{% for item in all_tags %}
{% if item.slug == tag %}
<div class="filter-wrapper2">
<label class="abc-filter">
<input type="checkbox" id="input-{{ tag }}" >
<span class="label-text">{{ item }}</span>
</label>
</div>
{% endif %}
{% endfor %}
{% endfor %}

View solution in original post

2 Replies 2
piersg
Solution
Key Advisor

How can display a Tag name with is link base on Tag ID

SOLVE

Hi @jc_at_dfuse (thanks for the tag @sharonlicari)

 

You can do this:

{% set all_tags = blog_tags('default', 250) %}
{% for tag in module.tag_field %}
{% for item in all_tags %}
{% if item.slug == tag %}
Name = {{ item }}
Slug = {{ tag }}
Full URL = {{ blog_tag_url(group.id, tag) }}
{% endif %}
{% endfor %}
{% endfor %}

 

But you have to set the value type to return to "Name" instead of "id" in the tag field

Screenshot 2020-07-27 at 10.36.24.png

So for you:

{% set all_tags = blog_tags('default', 250) %}
{% for tag in module.tag_field %}
{% for item in all_tags %}
{% if item.slug == tag %}
<div class="filter-wrapper2">
<label class="abc-filter">
<input type="checkbox" id="input-{{ tag }}" >
<span class="label-text">{{ item }}</span>
</label>
</div>
{% endif %}
{% endfor %}
{% endfor %}
sharonlicari
Community Manager
Community Manager

How can display a Tag name with is link base on Tag ID

SOLVE

Hey @jc_at_dfuse        

 

Thank you for the information provided. I'll tag a few experts.    

 

Hey @piersg @Chris-M @Anton  what would you advise in this case?      

 

Thanks 

Sharon


Join us on March 27th at 12 PM for the Digital Essentials Lab, an interactive session designed to redefine your digital strategy!
Engage with expert Jourdan Guyton to gain actionable insights, participate in live Q&A, and learn strategies to boost your business success.
Don't miss this opportunity to connect and grow—reserve your spot today!

0 Upvotes