Integrating Drupal with CiviCRM

Last updated on
25 April 2025

Presentation Slides and Resources

Support and documentation resources for CiviCRM

Project Home
http://www.openngo.org

Online Documentation
http://objectledge.org/confluence/display/CRM/CiviCRM+Documentation

API Doc and Snippets
http://objectledge.org/confluence/display/CRM/CiviCRM+Public+APIs

Mailing List (support and discussion)
http://lists.objectledge.net/mailman/listinfo/crm-dev

FAQs
http://faq.openngo.org/

Downloads
http://downloads.openngo.org/civicrm/

Roadmap
http://objectledge.org/confluence/display/CRM/OpenNGO+Roadmap

Issue Tracker
http://objectledge.org/jira/browse/CRM

Slides from the presentation

Agenda: OSCMS '06 - Integrating CiviCRM with Drupal

1. What the *!#k is CiviCRM?
2. CRM Core
3. Optional Components
4. Integration Approaches
5. CiviCRM Profiles
6. Simple PHP snippets - Read Access
7. Module integration
8. Two-way Integration w/ Hooks
9. Future Directions

1. What the *!#k is CiviCRM?

Constituent Relationship Management Platform
Non-profits, NGO's, Advocacy and Political Organizations
Fully Internationalized - Current Translations in
* Spanish
* German
* French
* Portuguese
Multiple CMS - Drupal & Joomla/Mambo
LAMP, PEAR libraries, PHP gettext for i18n

2. CRM Core

Data Store, API's, UI, Import and Export
* Contacts
* Locations
* Relationships
* Static and 'Smart' Groups
* Activities / Activity History
* Custom Properties for Contacts, Groups, Activities, Contributions

3. Optional Components

CiviContribute
* Configurable online contribution pages
* Plug-ins for PayPal and Moneris
* Online and offline contribution tracking
CiviMail
* High-capacity broadcast email
* Bounce-handling, open, click-thru, forward tracking
Coming
* CiviSMS
* CiviMember

4. Integration Approaches

CiviCRM Profiles
API's - invoke local PHP functions
* Simple PHP snippets in blocks
* Module Integration (read/write)
* Two-way Integration (CiviCRM hooks)
Remote invocation via SOAP "alpha"

5. CiviCRM Profiles

Expose search, listings, and insert forms w/o coding
Configure sets of core and custom fields
Built in pages or standalone forms
Linked to user registration, user account, or other modules/components

6. Read-only access via simple PHP snippets

*** Get sorted info for members of a 'named' group using search API ***

$myGroup = 'Newsletter Subscribers';

$results = getGroupMembers($myGroup);
if ($results) {
   echo '<h3>' . $myGroup . '</h3>';
   foreach ($results[0] as $myContact) {
       $string = 'ID: ' . $myContact['contact_id'] . ' ' .
            $myContact['sort_name'] . ', ' . $myContact['email'] . ', Phone: ' .
            $myContact['phone'];
       echo $string . '<br />---<br />';
   }
}
else {
   echo 'No group found with that name.';
}

function getGroupMembers($group_title) {
 // Check if CiviCRM is installed here.
 if (!module_exist('civicrm')) return false;

 // Initialization call is required to use CiviCRM APIs.
 civicrm_initialize(true);

 // Pass group 'title' to crm_get_groups to retrieve the group_id.
 $groups =& crm_get_groups(array('title' => $group_title));

 // Pass 'group' => group.id into search API to find members of that group
 // Only one group with that title, so we can reference
 // first object in returned array from get_groups.
 $params = array('group' => array($groups[0]->id => 1));

 // Define which contact fields should be retrieved
 $return_properties = array('sort_name' => 1, 'email' => 1, 'phone' => 1);

 // Define how we want the results sorted - also as an array.
 $sort = array('sort_name' => 'ASC');
 
 $contacts =& crm_contact_search( $params, $return_properties, $sort );
 if (!$contacts) return false;
 return $contacts;
}

7. Read/write module integration (Richard Orris / CivicActions)

Why do it? example of either event-finder or petitiion module
Demo / discuss key integration points
Code example(s) and tips (do's and dont's)

8. Two-way integration w/ hooks (Rob Thorne)

Why do it?
Demo / discuss key integration points
Code example(s) and tips (do's and dont's)
(disclosure on current state/hacks...)

9. Future directions for the platform

On our radar
* Finish/tweak hook implementation
* Better doc and more examples
* Remote invoke via SOAP
* Search improvements (UI and API) - esp flexible query building w/ AND, OR, more operators...
* Command-line import (large datasets)
* Report-writer integration
* Configurable core forms and listings

Contacts and other CiviCRM Objects <=> Nodes

Taxonomy Integration

Session Abstract, Resources and Expected Outcomes

Session Abstract

CiviCRM is an open source, internationalized, constituent relationship management (CRM) application, designed specifically to meet the needs of advocacy, non-profit and non-governmental organizations. CiviCRM is licensed under the AGPL, and comes with well-defined open APIs.

The purpose of this session is to introduce the APIs to the Drupal development community so that Drupal developers can start integrating CiviCRM objects such as contacts, profiles, relationships, groups and activity history into their modules.

CiviCRM is currently integrated with the e-commerce, event finder, location, mass mailer, organic groups, user, and volunteer modules. We will look at how to write modules to detect if CiviCRM is running, and use code examples to illustrate how developers can use CiviCRM's APIs to add the benefits of a structured CRM repository to their modules. Several individuals will be presenting integration examples, including brief code walk-throughs and tips.

We will also be soliciting discussion and input from the group on needed enhancements and future directions for CiviCRM API development.

NOTE: This is a presentation, not a moderated session. However, we will keep it informal and leave plenty of time for Q & A and discussion.

Resources

The Public APIs section of the CiviCRM wiki is currently the best resource for learning about available APIs. There is a growing set of code snippets in this section as well as a page of links to modules which use the APIs.

Outcomes

  • Attendees should leave with a better idea of the core CiviCRM entities, available APIs and examples of how those APIs can be used to allow modules to share a structured integrated data store of contact and contact interaction data.
  • Ideas generated for improving and extending CiviCRM APIs and API architecture and deepening the opportunities for integration with existing Drupal features.
  • More full examples and code snippets generated and posted as resources for new implementors.

Help improve this page

Page status: Not set

You can: