Skip to main content

Display All Tags on a Record in Templates

Show tags assigned to customers, invoices, or other records directly in your templates.

Kolleno Support avatar
Written by Kolleno Support
Updated this week

This feature allows you to display all tags already added to a record (such as a customer or invoice) inside email template.

You do not need to create new tags. The template simply shows the tags that already exist in Kolleno.


Available Parameters

Use this format in your template:

{% tags_with_dates record "record_type" as variable %}

Parameters Explained

Parameter

What to enter

record

The record used in the template (for example: customer or invoice)

record_type

The type of record, such as "customer" or "invoice"

variable

A name you choose to store the list of tags


Supported Record Types

You can display tags from the following records:

  • customer

  • customer_group

  • invoice

  • credit_note

  • kolleno_payment

  • account_transaction

  • email_received

  • email_sent


Tag Information You Can Use

Each tag includes the following information:

Property

What it shows

name

The name of the tag

color

The tag color

date_added

When the tag was added


How to Use It in a Template

Example 1: Show All Tags as a List

{% tags_with_dates customer "customer" as tags %} 
{% for tag in tags %} - {{ tag.name }}
{% endfor %}

Output:


Example 2: Show Tags as Colored Labels

{% tags_with_dates customer "customer" as tags %}
{% for tag in tags %}
<span style="background-color: #{{ tag.color }}; padding: 2px 8px; border-radius: 4px; color: white;">
{{ tag.name }}
</span>
{% endfor %}

Output:


Example 3: Show Tag Names and Dates

{% tags_with_dates invoice "invoice" as tags %}
{% if tags %}
<table>
<tr><th>Tag</th><th>Assigned On</th></tr>
{% for tag in tags %}
<tr>
<td>{{ tag.name }}</td>
<td>{{ tag.date_added|date:"d/m/Y" }}</td>
</tr>
{% endfor %}
</table>
{% endif %}

Output:


Example 4: Show How Many Tags Exist

{% tags_with_dates customer "customer" as tags %} 
{% if tags %}
This customer has {{ tags | length }} tag(s).
{% endif %}

Output:


Example 5: Show Tags in One Line

{% tags_with_dates customer "customer" as tags %} 
{% if tags %}
Tags:
{% for tag in tags %}
{{ tag.name }}
{% if not forloop.last %},
{% endif %}
{% endfor %}
{% endif %}

Output:


Example 6: Show the Most Recent Tag Only

{% tags_with_dates customer "customer" as tags %} 
{% if tags %}
{% with tags.0 as first_tag %}
Primary tag:
{{ first_tag.name }}
{% endwith %}
{% endif %}

Output:

Did this answer your question?