Skip to content

Instantly share code, notes, and snippets.

@backlineint
Created December 7, 2016 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save backlineint/dd356a0a2c507e61ee4fb6f5bb9373c8 to your computer and use it in GitHub Desktop.
Save backlineint/dd356a0a2c507e61ee4fb6f5bb9373c8 to your computer and use it in GitHub Desktop.
Creating a Delimited List of Referenced Taxonomy Terms
{# Prep specialties for display #}
{# TODO - Convert to field_target_entity_join custom twig filter #}
{# Get the render array for specialty taxonomy terms - this may be a single
object, or may be an array of objects #}
{% set entity = content.field_physician_specialty|field_target_entity %}
{# If we only have one value, set it #}
{% if entity.name.value is defined %}
{% set specialties = entity.name.value %}
{# If we have multiple values, iterate through and delimit #}
{% else %}
{% for item in entity %}
{% if loop.first %}
{% set specialties = item.name.value %}
{% else %}
{% set specialties = specialties ~ ', ' ~ item.name.value %}
{% endif %}
{% endfor %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment