Skip to main content
deleted 4432 characters in body
Source Link

Well we had some fun one week and made it happen. I thought I'd lob some code out into the community.

Maybe this isn't the right place or the right way...for those who ask this question though,But how would someone add this may help. Do with it what you will.

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
> 

Well we had some fun one week and made it happen. I thought I'd lob some code out into the community.

Maybe this isn't the right place or the right way...for those who ask this question though, this may help. Do with it what you will.

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
> 

But how would someone add this capability?

Source Link

How do I add custom fields to Personal Campaign Pages

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

The answer is you can't currently.

Well we had some fun one week and made it happen. I thought I'd lob some code out into the community.

Maybe this isn't the right place or the right way...for those who ask this question though, this may help. Do with it what you will.

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
>