2

Sorry this is probably a dumb question but I am a bit stuck in here and I can't find suitable solutions in google. Basically I have an item or a page with a Tagging on it. But I can't seem to get the value of tags using scriban template.

I tried using

{{i_item.tags}}

and

{{sc_raw i_item 'Tags'}}

and

      {{ for i_child in i_item.sxa_tags }}
        <span>{{ i_child.Title }}</span>
      {{ end }}

Anyhelp will be really appreciated. Thanks

1 Answer 1

5

Sample

Here is an example of how I used tags for listing departments associated with media items.

{{ if i_item.SxaTags != "" }}
<span>
Department: 
</span>
{{ tags = [] }}
{{ for i_tag in (sc_followmany i_item "SxaTags") }}
{{ tags[tags.size] = i_tag | sc_field "Title" }}
{{ end }}
{{ tags | array.sort | array.join ", " }}
{{ end }}
2
  • THANK YOUUU You save me hours mate! Cheers
    – keysl
    Oct 29, 2021 at 2:31
  • Thinking about it, I don't think it's convention to use the $ character in variables. Updated to reflect that. Oct 29, 2021 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.