Details
-
Type: Patch
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: Unscheduled
-
Component/s: CiviContribute, Core CiviCRM, Drupal Integration Modules
-
Labels:None
Description
The attached code adds Personal Campaign Page support to CiviCRM's integration with Drupal Views.
File civicrm/drupal/modules/views/civicrm.views.inc is patched to describe the civicrm_pcp table to Views and to tell Views about some new handlers. The result is a new View Type "CiviCRM Personal Campaign Pages," which, in addition to exposing the columns in the civicrm_pcp table, provides Views fields for:
(1) linking to the PCP (e.g., /civicrm/contribute/pcp/info?reset=1&id=1) or the PCP's contribution page (e.g., /civicrm/contribute/transact?id=1&pcpId=1&reset=1);
(2) displaying the total amount raised through the PCP; and
(3) displaying the image uploaded when the PCP was created (a relative URL is returned so that themers may pass the image through imagecache if they so desire).
Additionally, the Contact and Address views are joined to the PCP view so that a page may be associated with its owner and geographical location. The patch also makes PCP view's fields available to the CiviCRM Contact view type.
File civicrm/CRM/Core/PseudoConstant.php was modified to add a private static variable $pcpStatus and a public static function pcpStatus for translating database values to human-readable labels.
The attached code also includes five new handlers. It seems I've gotten accustomed to Git at the expense of SVN, as I had trouble getting what I wanted out of my SVN diff, so the handlers are included as separate files in the tarball rather than as part of the patch. The handlers should be placed in civicrm/drupal/modules/views/civicrm.
I need this code to meet the specific needs of a project I'm working on, but I've written it generically so that it may be incorporated into the project. My project does not utilize all of the fields exposed by this patch, so end-user testing is recommended to ensure that fields I wasn't interested in work as expected. This code was written against a CiviCRM install running on Drupal 6, but I believe the code will work on Drupal 7 as well. In any case, the attached code should make a good starting point for achieving the kind of Views integration required for displays like this one: http://giving.fpwr.org/contributions/campaigns (not my project).
While the code in the attachment is sufficient for the purposes of my project, I'd be happy to revisit this if there's interest in refining the code or adding more functionality.