1

I'm using Drupal 7 and Civicrm 4.4.1 and I enabled the Personal Campaign Pages so individuals can create campaigns. It comes with the standard default fields such as Title, Goal Amount, Welcome, and Your Message. I would like to add another field to that form which I can then access through views to display in a table.

The field I'd like to add is called sponsor, so I could then show the sponsor when listing a view of all Personal Campaign pages. I've tried creating a custom field dataset and applying it to the Contribution type that I'm using, but I didn't have any success.

Any ideas on how to create a custom field for these pages?

3 Answers 3

5

At this time, you cannot currently add custom data to Personal Campaign Pages (see the list at example.org/civicrm/admin/custom/group?action=add&reset=1). If you wanted to do that, your best bet would be to write the code (or pay someone to write the code) that does this, and get this contributed back into CiviCRM.

1

https://drupal.org/node/2234823

Using CiviCRM Custom Data Profiles

If your Drupal website is integrated with CiviCRM, you have an opportunity to bring much more personalized content into the Drupal user profile page through CiviCRM's Contact Record Fields. The most straight forward way to bring CiviCRM contact record data to the Drupal user profile page is by configuring the appropriate CiviCRM Custom Data Profiles to be visible in the Drupal user profile page. This can be done by being logged in with permissions to administer CiviCRM, navigating to CiviCRM -> Administer -> Custom Data and Screens -> Profiles. Edit the Profile you would like to expose in the user profile page and adjust the setting for it to be used for: View/Edit Drupal User Account. You can also use these settings to remove CiviCRM content from the Drupal user profile page by un-setting it to be used for the Drupal User Account.

1
  • Whilst true, this answer doesn't actually relate to the question being asked.
    – Graham
    Feb 11, 2015 at 8:43
0

Here's a patch to add custom field capability for PCP pages....

This diff is against CiviCRM 4.5.0

Doesn't output the custom fields on the template, but you can figure that part out :)

This will allow you to add custom field groups to the PCPs, and save values to them on PCP add/edit pages....

diff -r original/civicrm/CRM/Core/BAO/CustomGroup.php new/civicrm/CRM/Core/BAO/CustomGroup.php
1102a1103,1104
>       case 'Pcp':
>         $tableName = 'civicrm_pcp';
1168a1171
>       case 'Pcp':
1521a1525
> 
1698a1703,1704
>       case 'Pcp':
>         return 'civicrm_pcp';
1721a1728
>   
diff -r original/civicrm/CRM/Core/SelectValues.php new/civicrm/CRM/Core/SelectValues.php
179a180
>       'Pcp' => ts('Personal Campaign Pages'),
diff -r original/civicrm/CRM/Custom/Form/CustomData.php new/civicrm/CRM/Custom/Form/CustomData.php
54c54
<   ) {
---
>   ) { 
145c145
<     }
---
>     }   
diff -r original/civicrm/CRM/PCP/BAO/PCP.php new/civicrm/CRM/PCP/BAO/PCP.php
85c85,92
< 
---
>     //start custom field code addition
>     //store custom data
>     if (!empty($params['custom']) &&
>       is_array($params['custom'])
>     ) {
>       CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_pcp', $dao->id);
>     }
>     //end custom field code addition
diff -r original/civicrm/CRM/PCP/Form/Campaign.php new/civicrm/CRM/PCP/Form/Campaign.php
63a64,87
>     
>     //start custom field code additions
>     //check for custom data type.
>     $this->_cdType = 'Pcp';
>     $this->assign('cdType', FALSE);
>     if ($this->_cdType) {
>       $this->assign('cdType', TRUE);
>       $this->set('type', 'Pcp');
>       $this->set('entityID', $this->_pageId);
>       $this->set('cgcount', 1);
>       CRM_Custom_Form_CustomData::preProcess($this);
>     }
>     //end custom field code additions
>     
>         // when custom data is included in form.
>     if (!empty($_POST['hidden_custom'])) {
>       $this->set('type', 'Pcp');
>       $this->set('entityID', $this->_pageId);
>       $this->set('cgcount', 1);
>       CRM_Custom_Form_CustomData::preProcess($this);
>       CRM_Custom_Form_CustomData::buildQuickForm($this);
>       CRM_Custom_Form_CustomData::setDefaultValues($this);
>     }
> 
70c94,99
< 
---
>     //load only custom data defaults.
>     
>     if ($this->_cdType) {
>      $defaults = CRM_Custom_Form_CustomData::setDefaultValues($this);
>     }
>     
93c122
< 
---
>  
103a133,140
>     $this->assign('customDataType', 'Pcp');
>     $this->assign('entityID', $this->_pageId);
>    
>     if ($this->_cdType) {
>       CRM_Custom_Form_CustomData::buildQuickForm($this);
>     }
>     //lets assign custom data type and subtype.
>     
229c266,274
< 
---
>     
>        //process custom data.
>     $customFields = CRM_Core_BAO_CustomField::getFields('Pcp', FALSE, FALSE);
>     $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params,
>       $customFields,
>       $this->_pageId,
>       'Pcp'
>     );
>    
232d276
< 
Only in new/civicrm: groupcountsearch.txt
diff -r original/civicrm/templates/CRM/PCP/Form/Campaign.tpl new/civicrm/templates/CRM/PCP/Form/Campaign.tpl
97a98,120
> 
> {* load the custom data *}
> {if $cdType}
>     {include file="CRM/Custom/Form/CustomData.tpl"}
> {else}
> 
> {* include custom data js *}
> {include file="CRM/common/customData.tpl"}
> 
> {literal}
> <script type="text/javascript">
>   CRM.$(function($) {
>     {/literal}{if $customDataSubType}
>       CRM.buildCustomData( '{$customDataType}', {$customDataSubType} );
>     {else}
>       CRM.buildCustomData( '{$customDataType}' );
>     {/if}
>     {literal}
>   });
> </script>
> {/literal}
>   
> {/if} {* load custom data *} 
99a123
> 

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.