3

I bet that's a question that some people have asked before!

The answer is you can't currently.

But how would someone add this capability?

5

This diff is against 4.5.0 . It doesn't display the custom field values on the PCP view page, but it adds the capability to create custom field groups on PCP entities, and save values on 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
> 
  • This looks like a good start to a pull-request against the master branch for inclusion in the next version of CiviCRM. – Coleman May 8 '15 at 0:41
  • I haven't learned to do that yet, that's why I posted it here, but I guess its high time I learned....got a decent but slightly rough PCP api to contribute too – jackrabbithanna May 8 '15 at 0:50
  • views integration: Added two lines to this file: civicrm.views.inc, function civicrm_views_get_join_table(), around line 374 case "Pcp": return 'civicrm_pcp'; – jackrabbithanna May 8 '15 at 0:57
0

Since you have a working patch for this feature, you can share your changes with the rest of the community by submitting a Pull-Request to CiviCRM:

  1. Use buildkit to create a local sandbox site for yourself, based on the master branch.
  2. Create a new branch
  3. Apply your patch
  4. Push the branch to your fork on github
  5. Click the "Compare & Pull-Request" button on github.

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.