We use Campaign ID (renamed using Word Replacer to "Project ID") to categorize different kinds of contributions. Some come in through online contribution pages, and some are entered manually on CiviCRM after we receive cash or checks. I am customizing the "Contribution Invoice Receipt" system workflow message, and I tried to show the Campaign ID by using:

  • {$contribution.campaign_ID}
  • {capture assign=project_id1}{contribution.campaign_id}{/capture}{$project_id1}

None of these pull up the Campaign ID. And how come there are already contribution related fields in place in the template, such as $contribution_status_id or $amount? Is there a full list of fields available somewhere?

Once I identify the campaign id, I'm hoping to run something like

{if $campaignid==15}
Thanks for donating to Project 15! Bla bla (custom text)
{elseif $campaignid=17}
Thanks for becoming a member! Bla bla! (custom text)
Thanks for your donation! Bla bal (generic text)

So after searching further into the StackExchange I found this, which shows you can get the full list by inserting {debug} into the template, then the template outcome will show it as an email Javascript when viewing the source. Here is the cleaned up debug results, which indicates that the token to use may be $formValues.campaign_id. I then tested it, and turns out that it works on Contributions - Receipt (offline) and online, but not in Print Invoice.

Here is the list of formats that didn't work. (It seemed that on some paratemers CiviCRM was case sensitive)

{capture assign=project_id1}{contribution.campaign_id}{/capture}
{capture assign=project_id2}{contribution.Campaign_Id}{/capture}
{capture assign=project_id3}{contribution.campaign_Id}{/capture}
{capture assign=project_id4}{formvalues.campaign_id}{/capture}
{capture assign=project_id5}{formValues.campaign_id}{/capture}
{$project_id1} {$project_id2}  {$project_id3}{$project_id4}{$project_id5}
  • Welcome to Stack Exchange! Two responses: First - I see both "Contributions - Receipt (off-line)" and "Contributions - Receipt (on-line)" in Mailings » Message Templates but not "Print Invoice", so could you please edit your question to indicate where you're looking? Second - it appears you answered your own first question but then asked a second question. Stack Exchange isn't a forum - it works best as a Q&A site when there's one question per post. Just for future reference! Nov 23, 2016 at 18:20
  • Thanks! The template name was "Contribution invoice Receipt" (Screenshot: i.imgur.com/gIKde0X.png). I had customized the name of the template as well and I couldn't remember what the original name was.
    – Yongho Kim
    Nov 23, 2016 at 22:50
  • The list of variables available depends on the template you're using. Your link to the Smarty HTML on Dropbox isn't accessible to me (I don't have Dropbox). Is it a list of variables for the "Contribution - Invoice" template, or a different template? Dec 2, 2016 at 18:23
  • It's a list of variables for a different template, "Contributions - Receipt (offline). The "Contribution - Invoice" template does not generate an email, and using {debug} doesn't generate a hidden annotation like for the email ones. How can I view the variables list for PDF generating templates like "Contributions - Invoice"?
    – Yongho Kim
    Dec 20, 2016 at 18:20
  • That's a good question! I tried but couldn't figure it out quickly. You may want to ask that as a separate question. Since I know you have a relationship with my former employer (Palante), you may also want to pay them to research it. Dec 21, 2016 at 13:56

1 Answer 1


First off, I realize I am extremely late to the party - but I just read this question in the midst of trying to resolve a similar issue where I needed to know what template variables are available to a PDF template.

What I did to find template variables when {debug} isn't working for a direct download etc was:

In /CRM/Core/Smarty.php, Line 192 temporarily change

$this->security = TRUE;


$this->security = FALSE;

Let me emphasize that this is for a development environment ONLY. Please please please under no circumstances do this on a production site (you are turning off very important security features, I cannot emphasize that enough).

Now we can call protected functions in our smarty templates to print out all template variables in several ways. I did it this way:


From a quick glance at that, it didn't look to me like campaign information is available to this template already, and it looked like contribution_id is only available under 'line_item'... so I would put something like this in the message template (check out /civicrm/api/explorer for more examples):

{foreach from=$lineItem item=value key=priceset}
  {crmAPI var='result' entity='Contribution' action='getsingle' sequential=0 return='campaign_id' id=`$value.contribution_id`}
    {foreach from=$result item=youritem}
  • Interesting! Could you share what you get outputted when you make it print out all the template variables?
    – Yongho Kim
    Jun 15, 2018 at 3:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.