CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Usability Improvements (Moderator: Dave Greenberg) »
  • Smarty Templates for PDF Letters
Pages: [1] 2

Author Topic: Smarty Templates for PDF Letters  (Read 8459 times)

Marty

  • I post occasionally
  • **
  • Posts: 67
  • Karma: 14
    • Boulder County Arts Alliance
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.37
  • PHP version: 5.4.27
Smarty Templates for PDF Letters
March 28, 2010, 12:05:30 pm
Smarty can be used in email templates but apparently not in templates used for creating PDF letters.  Smarty tags used in printable PDF letters are passed directly to the PDF output without substitution.  Adding the ability to use Smarty templates for PDF letter creation would be of great value to me and probably the entire CiviCRM community.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Smarty Templates for PDF Letters
March 28, 2010, 04:44:10 pm

considering it would be great value to you, it would be great if you could either contribute a patch and/or sponsor a developer to do the needed work.

As an open source proeject, community contributions of code and resources help improve the project significantly

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Marty

  • I post occasionally
  • **
  • Posts: 67
  • Karma: 14
    • Boulder County Arts Alliance
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.37
  • PHP version: 5.4.27
Re: Smarty Templates for PDF Letters
March 28, 2010, 04:51:56 pm
I can certainly contribute the code for this enhancement.  Where do I learn the process for creating and submitting patches?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Smarty Templates for PDF Letters
March 29, 2010, 06:59:20 am

We dont have detailed instructions on how to do so, but will get a wiki page on this in the next few weeks. You might want to read:

http://civicrm.org/architecture (the earlier blog posts first) to get an idea of the code layout and what php/tpl files are relevant. You might also want to check how the current cases are handled.

Once you have a patch, please file an issue and attach the patch. Make sure you agree with the licensing: http://civicrm.org/licensing/

Ping us on IRC if you need help getting started: http://webchat.freenode.net/?channels=#civicrm

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Marty

  • I post occasionally
  • **
  • Posts: 67
  • Karma: 14
    • Boulder County Arts Alliance
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.37
  • PHP version: 5.4.27
Re: Smarty Templates for PDF Letters
July 17, 2010, 10:11:38 pm
Opened new issue and attached a patch.
http://issues.civicrm.org/jira/browse/CRM-6503

dschafer

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 3
    • Backoffice Thinking
  • CiviCRM version: 3.2.3 - 4.4.4
  • CMS version: Drupal 6.x, 7.x, Wordpress
  • MySQL version: 5.1.x - 5.5.x
  • PHP version: 5.2.x - 5.4.x
Re: Smarty Templates for PDF Letters
August 25, 2010, 07:44:22 am
According to issue CRM-6503 this item was added in 3.2

However it does not appear to work in 3.2.1

I inserted the following in a pdf message
{if '{contact.supplemental_address_1}'}<br />
   &nbsp;&nbsp; &nbsp;&nbsp;{contact.supplemental_address_1}<br />
{/if}

and got this output

Dear The Rev. H. Emerson Abram ,
{if ''}

{/if}

Was this really included in the release?

If not, is it available as a patch?

Thanks


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Smarty Templates for PDF Letters
August 25, 2010, 07:55:50 am

did u add

define( 'CIVICRM_MAIL_SMARTY', 1 );

in your civicrm.settings.php file?

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

dschafer

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 3
    • Backoffice Thinking
  • CiviCRM version: 3.2.3 - 4.4.4
  • CMS version: Drupal 6.x, 7.x, Wordpress
  • MySQL version: 5.1.x - 5.5.x
  • PHP version: 5.2.x - 5.4.x
Re: Smarty Templates for PDF Letters
August 25, 2010, 08:29:48 am
Sorry didn't know I needed to.

Added it and restarted the site.

Got the same result.
Also got the same result on the demo site.

--Dave

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Smarty Templates for PDF Letters
August 25, 2010, 09:55:29 am

that was a contributed patch, so we did not test it

The demo site does not have CIVICRM_MAIL_SMARTY enabled (since the whole world is an admin on that site)

would be great if you can debug the lines of code in PDFCommon.php near the lines CIVICRM_MAIL_SMARTY and see what is happening and why

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Marty

  • I post occasionally
  • **
  • Posts: 67
  • Karma: 14
    • Boulder County Arts Alliance
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7.26
  • MySQL version: 5.5.37
  • PHP version: 5.4.27
Re: Smarty Templates for PDF Letters
August 25, 2010, 09:32:40 pm
I'm running 3.2.1 and Smarty templates are working fine for me in PDF letters.  Have you tried your template in an email message to see if it works there?

resga

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 3
  • CiviCRM version: 3.4.2
  • CMS version: Drupal
  • MySQL version: 5.1.41
  • PHP version: 5.3
Re: Smarty Templates for PDF Letters
February 19, 2011, 01:39:18 pm
If I insert define( 'CIVICRM_MAIL_SMARTY', 1 ); in my civicrm.settings.php file, and Print letter (PDF) the result is empty content, like this:
Membership Values are
Membership Id =
Membership Status Id =
Member Contact Id =

If the define( 'CIVICRM_MAIL_SMARTY', 1 ); is omitted, the result is:
Membership Values are
Membership Id = {$memberParams.id}
Membership Status Id = {$memberParams.status_id}
Member Contact Id = {$memberParams.contact_id}

So it does makes a difference, but the data isn't printed... Does anyone know where I should start the debugging?

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Smarty Templates for PDF Letters
February 20, 2011, 08:25:33 pm
First guess is that those smarty variables are not defined or empty. If you're able to enable Debugging in your site (i.e. site is not in production) - then you do so (Administer > Global Settings > Debugging -> Enable Debugging. Then add this code somewhere in the mail template and "I think" it will spit out a table with all the available smarty variables. (Caveat - haven't tried this recently, but I think I'm remembering properly that this works).
Protect your investment in CiviCRM by  becoming a Member!

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Smarty Templates for PDF Letters
February 20, 2011, 10:59:50 pm
@Dave,

seems that your code has been swallowed by the forum?

I'm assuming it was
Code: [Select]
{debug}
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

resga

  • I post occasionally
  • **
  • Posts: 38
  • Karma: 3
  • CiviCRM version: 3.4.2
  • CMS version: Drupal
  • MySQL version: 5.1.41
  • PHP version: 5.3
Re: Smarty Templates for PDF Letters
February 21, 2011, 03:40:54 am
Thanks for getting me started! I found an alternative way of turning on debugging by adding &smartyDebug=1 at the end of the query string (http://civicrm.org/node/100 - see under "Debugging Templates")

But the only tokens available are from the type contact content type, starting with {contact. and then something, like {contact.addressee}
------------
NOTE to other debuggers: The information strings page were getting truncated at around 40 characters ("{$tokens}    "{"{contact.addressee}":"Addressee","{..."") so I updated the modifier.debug_print_var.php file. I changed $length = 40 to $length = 4000, for all available tokens to be shown.
« Last Edit: February 21, 2011, 12:03:15 pm by resga »

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Smarty Templates for PDF Letters
February 21, 2011, 10:59:09 am
Check out the Tokens hook - pretty sure you can define additional tokens using that hook:
http://wiki.civicrm.org/confluence/display/CRMDOC33/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmtokens
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Usability Improvements (Moderator: Dave Greenberg) »
  • Smarty Templates for PDF Letters

This forum was archived on 2017-11-26.