GitHub Download

{{#getTags}} helper

{{getTags}} is a helper used to retrieve tags data regardless of the current context.

Syntax:

{{#getTags "TAG_ID1,TAG_ID2,TAG_ID3" "before" "after"}}
...
{{/getTags}}

Example:

{{#getTags "1,2,3" "<ul>" "</ul>"}}
<li>
    {{ name }} ({{postsNumber}})
</li>
{{/getPosts}}

Tags are ordered by the ID order in the string.

You can also use the @index variable to detect the tag number in the specified collection:

{{#getTags "1,2,3" "<ul>" "</ul>"}}
<li>
{{ name }} ({{postsNumber}})
{{#checkIf @index '==' 0}}
<small>IT'S THE FIRST ELEMENT!</small>
{{/checkIf}}
</li>
{{/getTags}}

The second parameter creates HTML prefix, the third parameter creates HTML suffix for the generated output.

IMPORTANT: It requires availability of the @website.contentStructure global variable

Subscribe

Get the latest Publii news, updates and more delivered directly to your email inbox

You can change your mind at any time by clicking the unsubscribe link in the footer of any email you receive from us, or by contacting us at contact@tidycustoms.net. By clicking below, you agree that we may process your information in accordance with our Privacy Policy.