I have a series of paragraphs items representing two different types of contributors to a publication: staff (user link) and non-staff (text). (See How to control the display of a user account connected via entity reference)
According to Paragraphs preprocess paragraphs handles building the render array for its items in the same way as nodes, comments, etc, so maybe my question is much broader, but here's what I'm trying to do:
I want to send up with a basic comma separated list of items:
Person 1
or
Person 1 and Person 3
or
Person 1, Person 2, and Person 3
with links on the items that should be links. I guess I just am not getting render arrays and the theming functions well enough yet, that I understand how to do it.
The paragraphs preprocess question makes me think maybe I should be overriding the fields_formatter, but what I've been working on up to this point is theme_preprocess_paragraphs_items()
. That seems like it should allow me to do what I want, I can see that I could loop through $variables['element']['#items']
or maybe the integer keys of $variables['element']
, but how to change those so that they append ', ' or ', and ' or whatever as appropriate (outside of the link on link items is escaping me). (I do understand how to determine what should be appended, just not where to append it to make drupal output what I want.