Created
December 7, 2016 14:58
-
-
Save backlineint/dd356a0a2c507e61ee4fb6f5bb9373c8 to your computer and use it in GitHub Desktop.
Creating a Delimited List of Referenced Taxonomy Terms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# 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