diff --git a/docs/channels/emails.rst b/docs/channels/emails.rst index 61005612..9b6057cb 100644 --- a/docs/channels/emails.rst +++ b/docs/channels/emails.rst @@ -187,6 +187,28 @@ To use custom date fields in tokens, use the following format: 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'. +Label modifier for select and boolean fields +-------------------------------------------- + +For select and boolean field types, you can display the human-readable label instead of the stored value by using the ``|label`` modifier: + +.. code-block:: php + + {contactfield=select_alias|label} + {contactfield=bool_alias|label} + +This is particularly useful when these fields contain technical values, but you want to show user-friendly labels in your Emails. For instance: + +* A country selection field storing ``us`` can display ``United States`` +* A boolean field storing ``1`` can display ``Yes`` + +The modifier also works with Company fields: + +.. code-block:: php + + {contactfield=company_select_alias|label} + {contactfield=company_bool_alias|label} + Contact replies =============== diff --git a/docs/configuration/variables.rst b/docs/configuration/variables.rst index 9be629ee..8cd35c3d 100644 --- a/docs/configuration/variables.rst +++ b/docs/configuration/variables.rst @@ -8,6 +8,41 @@ Variables ``Hi {contactfield=firstname|there},`` +Token modifiers +*************** + +Label modifier for select and boolean fields +============================================ + +For select and boolean type fields, you can use the ``|label`` modifier to display the human-readable label instead of the stored value. It's beneficial when your select fields store values like codes or IDs, but you want to display friendly labels to your Contacts. + +**Syntax:** + +.. code-block:: text + + {contactfield=field_alias|label} + +**Examples:** + +* For a select field with alias ``country_select`` that has options, such as ``us`` for ``United States`` or ``uk`` for ``United Kingdom``: + + * ``{contactfield=country_select}`` displays the value ``us`` + * ``{contactfield=country_select|label}`` displays the label ``United States`` + +* For a boolean field with alias ``is_subscriber``: + + * ``{contactfield=is_subscriber}`` displays the value ``1`` or ``0`` + * ``{contactfield=is_subscriber|label}`` displays the label ``Yes`` or ``No`` + +* For both Contact fields and Company fields: + + * ``{contactfield=company_type|label}`` displays the label of a Company select field + * ``{contactfield=company_active|label}`` displays the label of a Company boolean field + +.. note:: + + The ``|label`` modifier only works with select and boolean field types. For other field types, it displays the regular value. + Contact fields **************