2

Via the Drupal GUI, I have created the following content types and fields:

ContentType(Company)

ContentType(Site)
    Field(Company) <- entity reference to Company content type

ContentType(Contact)
    Field(Company) <- entity reference to Company content type
    Field(Site)    <- entity reference to Site content type

I'm trying to make a view (via the Views UI) which outputs a table like this:

-------------------------------------------
Company1    Site1   Contact1
-------------------------------------------
Company2    Site2   Contact2, Contact3
-------------------------------------------

I.e if two or more contacts are related to the same Company\Site combination, the output should be one row only, with all Contacts concatenated (with ", " as a separator in the example above).

But all I get is:

-------------------------------------------
Company1    Site1   Contact1
-------------------------------------------
Company2    Site2   Contact2
-------------------------------------------
Company2    Site2   Contact3
-------------------------------------------

Is there any way to get the output I want?

3

I know this is old but maybe it will help someone. I have found two possibilities, both with certain downsides.

  • Views merge rows module does exactly what you need in terms of displaying results, however it messes up views pagination because it only changes the display of the query. But if you don't need pagination it's the way to go. Edit: I wrote a patch for the Views merge rows module to address the pagination issue. It now works perfectly.

  • Views Aggregation with concat function patch - if patching is an option - do it, then enable aggregation under Advanced in the view. Next step is to click on aggregation settings under the right field (in your case the 'contact' field) and set it to 'group concat'. This will aggregate the company and contact field and summarize the contact data as you specified.

Whereas this should work for the majority of use cases both solutions don't work for mine, that's why I created a new question here. Kind regards.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.