1

I'm trying to edit the Thankyou.tpl smarty template to expose certain information on the Thank You page after a donation is submitted. Following the CiviCRM wiki it looks like, for instance, printing just the first name of the donor on that page should be able to be done using {$profileFields_1.first_name.value} - but this doesn't give me the result I'm looking for.

I know that I can print the full name using {$billingName} but I need to be able to pull just the first name and a couple of other address fields. Any ideas?

2

Add {debug} to your .tpl and you will find all available variables. Not all expected variables are available in all template.

One way to get more variables in the .tpl file is to use the API in smarty code.

More info about {debug}: https://wiki.civicrm.org/confluence/display/CRMDOC/Debugging+for+developers

More info about using the API in smarty: https://wiki.civicrm.org/confluence/display/CRMDOC/Smarty+API+interface

| improve this answer | |
  • Thank you @Catorghans. I knew the variables weren't exposed to the template, but I wasn't aware of the options for the Smarty API. I played with it for a while and couldn't seem to get data related to just the current donation, or figure out sorting. So, I ended up adding PHP code to expose the variables to the Smarty template. – Jacobo Apr 11 '16 at 20:56
-1

I ended up solving this by following existing code examples in the two files below (I know this is a hack of core files, but we are moving away from Civi and won't be upgrading).

The examples below expose the 'first name' contact field as {$billingFirstname} in the smarty templates (to be used in my ThankYou.tpl file).

CRM/Contribute/Form/AdditionalInfo.php:

$myvariable = CRM_Utils_Array::value( 'billing_first_name', $params );
$this->assign( 'billingFirstname', $myvariable );

CRM/Contribute/Form/ContributionBase.php:

$myvariable = CRM_Utils_Array::value( 'billing_first_name', $this->_params ); $this->assign( 'billingFirstname', $myvariable ); $this->set( 'myvariable', $myvariable );

| improve this answer | |

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.