8

Can someone tell me what I need to use Views with CiviCRM? Is it the regular Drupal Views module with another module that provides integration?

Also, how would I use Views to display a count of how many people are registered for each of my events?

2

Also note that if you are using custom fields in your views you have to check the permission Access all custom data. For all people using views. If drupal cache is cleared the views are rebuild based upon the role the user who is clearing the cache, meaning that the custom field permission will be checked against that user.

11

It is the regular Drupal Views module, but if you have Drupal and CiviCRM in separate databases, you have to edit your settings file to let Views know where to find the CiviCRM data. (Coleman notes in addition: "if your drupal sql user and civicrm sql user are different then you need to grant SELECT privileges to the drupal one for the civi db.") You can find the information you need to add to settings.php at Administer > System Settings > CMS Database Integration.

The wiki page has a pretty good tutorial on how to get Views working.

Then you can use default Views functionality on CiviCRM data -- for example:

  • set up a View for CiviCRM Participants,
  • turn on Views aggregation,
  • add the Event Title field (Aggregation settings: Group together)
  • add the Participant ID field (Aggregation settings: Count)
  • Thanks - you've been a great help. I now have a nice little block with a table showing the number of registrants for all my upcoming events. – tmccartney May 8 '15 at 20:53
  • @tmccartney Don't forget to mark this answer as correct with the checkmark please! – Jon G - Megaphone Tech May 8 '15 at 21:29
  • If this answer gets 'accepted' can you edit it to make reference to fact that the instructions only apply if civi is in a separate DB - as per coleman's answer - no need to confuse people who have Drupal and civi in same db ;-) – petednz - fuzion May 10 '15 at 21:22
3

CiviCRM ships with a bundled module for Views 3 integration, all you have to do is turn it on.

If you are using a separate db for Civi, you'll also need to follow the instructions at Administer > System Settings > CMS Database Integration. Note that if your drupal sql user and civicrm sql user are different then you need to grant SELECT privileges to the drupal one for the civi db.

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.