Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Display suite has a handy field formatter for outputting terms in a single field comma separated (space, dash and slash alos available) as a single string. The labels can be either linked or not linked.
There is also exposed a drupal_alter to allow developers to add additional separators.
I have basically implemented this into the entityreference module which I will make available as a patch. I would love to see it accepted.
Comment | File | Size | Author |
---|---|---|---|
#8 | 1980836-8.patch | 3.82 KB | rpayanm |
| |||
#4 | entityreference-separator_field_formatter-1980836-4.patch | 3.86 KB | brunodbo |
#2 | entityreference-separator_field_formatter-1980836-2.patch | 3.23 KB | nlisgo |
#1 | entityreference-separator_field_formatter-1980836-1.patch | 3.29 KB | nlisgo |
Comments
Comment #1
nlisgo CreditAttribution: nlisgo commentedHere is the patch. Please review.
Comment #2
nlisgo CreditAttribution: nlisgo commentedLooking at the code more closely I recognise that the limit feature (introduced by display suite) is not working the patch in #1. This is an error I brought across from the ds taxonomy term separator formatter code. This latest patch addresses that.
Comment #3
StevenWill CreditAttribution: StevenWill commentedThis is a much needed patch. For the most part the patch works, but the display is still wrapping each entity reference in Divs and causing them to not be on the same line. The display suite taxonomy term wraps all terms in one div.
Comment #4
brunodboAttached patch addresses the issue of each entity reference being wrapped in a div, by adding all field items in the first result item. This also gets rid of some unwanted spaces between items.
I also added an option to separate the last item with an ampersand, especially useful when separating items with a comma.
Comment #5
brunodboUpdating title.
Comment #6
brunodboJust found https://www.drupal.org/project/textformatter, which supports Entity reference.
Comment #7
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 4 year old patch in #4 to entityreference.module does not apply to the latest 7.x-1.x-dev and if still relevant needs a reroll.
Comment #8
rpayanmComment #9
rpayanm