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

SOLVE
jc_at_dfuse
Member

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

Accepted Solutions
piersg
Solution
Key Advisor

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
sharonlicari
Community Manager

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


¿Sabías que la Comunidad está disponible en Español?
¡Participa hoy en conversaciones en el idioma de tu preferencia,cambiando el idioma en tus configuraciones!

Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !


0 Upvotes
piersg
Solution
Key Advisor

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