0

Ok, this should be very straight forward but it doesn't appear to be.

I have a CiviCRM Contact View in Drupal 7. It is a contact search of sorts. When a contact is rendered a number of things are displayed. The contacts can be a member of one or more CiviCRM Groups and I would like to display a comma delimited list of the groups that each contact belongs to. At present Drupal Views only displays the first group.

Any ideas of how to render more?

2 Answers 2

2

You can use Views Aggregator Plus module to group contact 2 rows.

Views Setting enter image description here

Table format setting enter image description here

Result enter image description here

HTH

Pradeep

2
  • Thank you @Pradeep Nayak. I'll give that a whirl and report back. Jun 28, 2018 at 17:53
  • I'm not sure that this will work for me. I'm using a display type of unordered list and I plan to Have the Firstname, Lastname + Groups on one line in my rendered view. I'll have a look at this further later today and see if I can use it. Aside from the need of a table display type, it does exactly what I want it to do. Jun 28, 2018 at 18:06
1

I've resolved this for my needs and here is my solution in case anyone else needs to do the same thing.

I would have liked to use the Views Aggregator Plus module however I am not using a table for rendering my results and I have somewhat specific needs for the way the results are formatted.

My solution was to create Custom Views Field and in my field handler, I queried the CiviCRM API to pull all of the Groups per Contact ID. In order to limit the Groups to the ones I wanted to render, I used the Visibility setting for "Public Pages" and put a conditional in the loop that produces the results.

Hooks: hook_views_data() hook__views_api()

In my views filed handler inc file I created a class that extends views_handler_field to run my logic and return my results.

I acquired the contact id and placed it in avariable called $contactid then used the following CiviCRM API code to get my groups array

$groups = civicrm_api3('GroupContact', 'get', array(
  'sequential' => 1,
  'contact_id' => $contactid,
));

The rest was pretty straight forward looping and concatenating the string of Group Titles.

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.