BlogTags with AJAX

Blog tags for rainlab.blog plugin

Back to BlogTags with AJAX Support

perklapoint26826
perklapoint26826

Hello! Congrats on a superb plugin! It works just fine. Following the examples I could list all tags associated to a post, but I need to show only the first tag. How can I do it? Also how can I list all tags but the first?

thanks!

Last updated

Surahman
Surahman

You can get the first tag from collection like this post.tags.first

perklapoint26826
perklapoint26826

Thank you! Not sure how to implement it though! Like this?

{% for tag in post.tags %} {{post.tags.first}} {% endfor %}

Because using only {{post.tags.first}} returns the following:

{"id":7,"name":"19","slug":"19","created_at":"2018-05-07 04:17:13","updated_at":"2018-05-07 04:17:13","pivot":{"post_id":6,"tag_id":7}}

What about listing all but the first? :)

Last updated

Mennax
Mennax

What about listing all but the first? :)

Maybe:

{% for tag in post.tags %}
    {% if loop.index > 1 %}
    {% endif %}
{% endfor %}

Last updated

Surahman
Surahman

paolo.26805 said:

What about listing all but the first? :)

Maybe:

{% for tag in post.tags %} {% if loop.index > 1 %} {% endif %} {% endfor %}

Do you mean listing all tags except the first?

If you want to listing all except the first tag you can use slice

{% for tag in post.tags[1:] %}
{% endfor %}

1-5 of 5