0

How do I change this text “This contribution is being made thanks to the effort of [contact name], who supports our campaign.You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!”

I’ve searched high and low - every tpl file in contribute/pcp etc Is it hardwired somewhere?

Thanks all.

  • interesting timing - we have just had to do the exact same thing - clearly there is room for some improvements to the PCP options via the UI – petednz - fuzion Oct 9 '18 at 0:55
2

Lesley,

This is set in php and then assigned to tpl. It's being set from two places CRM/Contribute/Form/Contribution/Main.php and CRM/PCP/BAO/PCP.php. Since its being assigned to tpl through php then its pretty simple and easy to change the text using either preprocess/buildform/postprocess hook by over-riding the tpl variable.

Here are list of lines that uses the variable to print the text

templates//CRM/Contribute/Form/Contribution/Main.tpl:177:    {if $pcpSupporterText}
templates//CRM/Contribute/Form/Contribution/Main.tpl:178:    <div class="crm-public-form-item crm-section pcpSupporterText-section">
templates//CRM/Contribute/Form/Contribution/Main.tpl:180:      <div class="content">{$pcpSupporterText}</div>
templates//CRM/Event/Form/Registration/Register.tpl:61:    {if $pcpSupporterText}
templates//CRM/Event/Form/Registration/Register.tpl:62:      <div class="crm-public-form-item crm-section pcpSupporterText-section">
templates//CRM/Event/Form/Registration/Register.tpl:63:        <div class="content">{$pcpSupporterText}</div>

If you not familiar with using php then you can JS to replace the text. Here is what i would do

  1. Create a Main.extra.tpl under templates/CRM/Contribute/Form/Contribution/ (custom template directory or extension)
  2. Add below snippet in Main.extra

Snippet:

{if $pcpSupporterText}
<div class='crm-pcp_supporter_text_replace'>
  <div class='content'>
    {ts}Text to print{/ts}
  </div>
</div>

{literal}
  <script type="text/javascript">
    CRM.$(function($) {
      $("div.pcpSupporterText-section .content").replaceWith($('.crm-pcp_supporter_text_replace .content'));
    });
  </script>
{/literal}

{/if}

HTH

Pradeep

  • Thanks Pradeep - no wonder I couldn’t find a tpl file! – LesleyJill Oct 8 '18 at 2:20
  • LesleyJill i have updated my answer with a list where the variable is used. – Pradeep Nayak Oct 8 '18 at 7:43
  • Thanks so much for those links - I don't know how to use hooks, but I think I can override template variables... or maybe not? – LesleyJill Oct 9 '18 at 5:51
  • I have copied Main.tpl to custom_templates/CRM/Contribute/Form/Contribution. I changed line 174 to <div class="content">{ts}My text{/ts}</div>. I cleared templates_c directory and browser cache. But the text remains as original. Am I missing something? Really appreciate your help with this. Oh and I'm on wordpress – LesleyJill Oct 9 '18 at 5:58
  • LesleyJill, I have updated my answer on how you can do it using tpl. Personally i would hate to over-ride core file because its a pain during CiviCRM upgrade and Main.tpl is an important file and keeps changing. Let me know how it goes. – Pradeep Nayak Oct 9 '18 at 9:20
1

Lesley - better to write this in an extension rather than overriding a core file. You can place the below hook in any of your custom extension or create one using civix

As Peter Davis said in the comment, we just made this changes for one of our client using -

function example_civicrm_buildForm($formName, &$form) {
  if ($formName == 'CRM_Contribute_Form_Contribution_Main' && !empty($form->_pcpId)) {
    $form->assign('pcpSupporterText', 'your custom pcp text');
  } 
}

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.