You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: add documentation for contact field label modifier
Add documentation for the new < /dev/null | label modifier that displays human-readable labels for select and boolean contact fields instead of stored values.
Related to mautic/mautic#12620
Copy file name to clipboardExpand all lines: docs/channels/emails.rst
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -141,6 +141,28 @@ To use custom date fields in tokens, use the following format:
141
141
142
142
The date outputs in a human-readable format, configured in the settings in your Global Configuration > System Settings under 'Default format for date only' and 'Default time only format'.
143
143
144
+
Label modifier for select and boolean fields
145
+
---------------------------------------------
146
+
147
+
For select and boolean field types, you can display the human-readable label instead of the stored value by using the ``|label`` modifier:
148
+
149
+
.. code-block:: php
150
+
151
+
{contactfield=select_alias|label}
152
+
{contactfield=bool_alias|label}
153
+
154
+
This is useful when your select fields store technical values but you want to display user-friendly labels in your Emails. For example:
155
+
156
+
- A country select field storing ``us`` can display ``United States``
157
+
- A boolean field storing ``1`` can display ``Yes``
Copy file name to clipboardExpand all lines: docs/configuration/variables.rst
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,40 @@ Variables
8
8
9
9
``Hi {contactfield=firstname|there},``
10
10
11
+
Token modifiers
12
+
***************
13
+
14
+
Label modifier for select and boolean fields
15
+
=============================================
16
+
17
+
For select and boolean type fields, you can use the ``|label`` modifier to display the human-readable label instead of the stored value. This is particularly useful when your select fields store values like codes or IDs but you want to display friendly labels to your Contacts.
18
+
19
+
**Syntax:**
20
+
21
+
.. code-block:: text
22
+
23
+
{contactfield=field_alias|label}
24
+
25
+
**Examples:**
26
+
27
+
For a select field with alias ``country_select`` that has options like ``us`` (United States), ``uk`` (United Kingdom):
28
+
29
+
- ``{contactfield=country_select}`` - displays the value: ``us``
30
+
- ``{contactfield=country_select|label}`` - displays the label: ``United States``
31
+
32
+
For a boolean field with alias ``is_subscriber``:
33
+
34
+
- ``{contactfield=is_subscriber}`` - displays the value: ``1`` or ``0``
35
+
- ``{contactfield=is_subscriber|label}`` - displays the label: ``Yes`` or ``No``
36
+
37
+
This modifier works for both Contact fields and Company fields:
38
+
39
+
- ``{contactfield=company_type|label}`` - displays the label of a company select field
40
+
- ``{contactfield=company_active|label}`` - displays the label of a company boolean field
41
+
42
+
.. note::
43
+
The ``|label`` modifier only works with select and boolean field types. For other field types, it will display the regular value.
0 commit comments