Questions tagged [smarty]

Questions relating to CiviCRM's use of the Smarty templating syntax.

Filter by
Sorted by
Tagged with
10
votes
4answers
642 views

How can I include a custom template file in an email template using smarty?

Details We would like to create a standard header and footer for our email templates. Rather than pasting the custom HTML in the top of each system email template we want to override, it would be ...
7
votes
3answers
754 views

How can I see the available tokens for message templates?

For a page in the browser, we can put &smartyDebug=1 in the URL to see variables in scope for the top level template. How can we do this for message templates?
7
votes
1answer
405 views

Can I create a custom System Workflow Message for a particular Contribution Page?

I need to create a custom system workflow message for Contributions - Receipt (on-line) that will be used instead of the default template when a particular contribution page is used. I already ...
6
votes
3answers
1k views

How can I run a php script to display API response with social media information for a contact

OK so I am interested in displaying social media account information for my contacts. Attentiv.ly looks awesome but very expensive :(( So I have been investigating other options and can now ...
6
votes
7answers
937 views

How can I add/rearrange custom fields in the default contact view template?

We would like to rearrange the output of custom fields on the basic contact view page (in Drupal, /civicrm/contact/view?cid=NNNN&reset=1) in CiviCRM 4.5 on Drupal 7. Specifically, since this is a ...
6
votes
3answers
851 views

Escaping quotes in ckeditor breaks smarty-syntax

The ckeditor has the habit to escape characters like quotes or umlauts. This breaks the smarty-syntax when generating PDFs or mails. Is there a good work-around or solution?
6
votes
1answer
88 views

How to go about making a Core Tab on the Contact Summary screen view Inline instead?

Specifically -> I'd like to see what's in the Membership Tab -> Inline instead. I'd like that table with Active Memberships printed right at the top underneath the Display Name on civicrm/contact/view?...
6
votes
1answer
1k views

Can I format a smarty token number to have thousands comma?

Based upon smarty documentation I should be able to do something like this {contribution.total_amount|number_format:2:".":","} and get something like 1,234.56, but it shows blank. In the logs I see:...
5
votes
0answers
69 views

Smarty tokens in postal mailing labels?

Total newbie here, but am I correct in my understanding that Smarty tokens do not function in the postal mailing label template? I have them enabled and can see them working in email and PDF letters, ...
4
votes
1answer
48 views

Smarty only generating nulls from API calls

Using the Explorer, I built up the smarty code I need for a template to pull in address information on a contact for use in an email: {crmAPI var='result' entity='Address' action='get' contact_id=203}...
4
votes
1answer
35 views

Issue with sending html email from civicrm with Smarty

I am testing some templates with smarty and I don't succeed to send them when the email is - apparently - encoded in html. I could send them as normal text message. I could also send html templates ...
4
votes
1answer
59 views

Smarty and future proof code

I am trying to be a more conforming civicrm coder. Smarty used by civicrm for pages (and forms?) I have never used Smarty.. Is it going to be part of civicrm going forward? And are there any tips ...
4
votes
2answers
118 views

Is it possible in CiviCRM to change extension of cached php files from .php to something else (e.g. .php_ or .txt)?

Is it possible in CiviCRM to change extension of cached php files from .php to something else (e.g. .php_ or .txt)? Our host (WPEngine) does not allow guest users to write to php files on production ...
3
votes
2answers
225 views

How to check if a contact has an active membership in a smarty template?

Is there a variable that one can use in smarty in a message template to simply determine if a contact has an active membership?
3
votes
1answer
46 views

How to set a id attribute to button?

I am creating a button using php pear. Button (php code) $this->addButtons(array( /** * Array for 'next' button */ array( 'type' => 'next', 'name' => E::ts('Next'), ...
3
votes
1answer
114 views

SMARTY error with template

I have this issue I don't understand with a civirule that should be sending an email with a .pdf attached when adding a member to a group but it's blocked by Smarty during the process of merging the ...
3
votes
1answer
38 views

How to suppress translation of months (or all fields) in receipts?

My platform: CiviCRM 5.16.3 on Drupal 7.6.7 PHP 7.2 CentOS 7. Drupal language is English. CiviCRM l10n installed and selected my own languange zh_TW Chinese(Taiwan). At receipt print-outs CiviCRM ...
3
votes
1answer
30 views

Issue with CK editor <wbr> tag appearing in Token

In the CK editor, when I add a token and look at the source code, the wbr/> tags appear in the token breaking the token. I have a feeling this crept in after I enabled Smarty for email. Does anyone ...
3
votes
2answers
122 views

Smarty and Mosaico - compatibility?

Seeing a lot of smarty errors in Drupal log file for mailings using Mosaico template - looks like an error for every message sent so thousands filling log files. Nothing obvious in Mosaico template ...
3
votes
2answers
224 views

What hook(s) can modify variables passed into Smarty templates?

Recently I needed to modify Smarty variables being passed into a template from an extension. I tried a couple of likely hooks, but neither of them seemed to provide this functionality. The templates ...
3
votes
0answers
36 views

Adding conditional content in message template for emails, but not for PDFs

I'm wondering if it's possible to add some conditional logic in my custom user-driven message template to show some content (in this case, a footer) for messages that are sent as emails, but not to ...
2
votes
1answer
138 views

How to deal with ' or (&#39;) in CKeditor

I am unable to use smarty in CKeditor because it's transforming the ' into & #39; I couldn't find anything useful when click the configure CKEditor Button in display preferences.
2
votes
2answers
431 views

Override TPL path dynamically

Is it possible to dynamically override the .tpl file path in CiviCRM? Rather than use the corresponding TPL file to the Class.
2
votes
1answer
154 views

Custom Email Greeting token doesn't work

I've done a custom email greetings that have this structure: {capture assign=l}{contact.preferred_language}{/capture} {capture assign=g}{contact.gender}{/capture} {if $l=="en_US"}Dear {elseif $l=="...
2
votes
1answer
196 views

Contribution Note Smarty Variable

So I'm super close to getting a smarty variable working to place the contribution note in a thank you letter. I used the API explorer and got this far: {crmAPI var='result' entity='Note' action='...
2
votes
1answer
37 views

Thank-you letter incorrect contribution currency

My setup: CiviCRM 5.20.0 on Drupal 7. I entered contributions in different currencies. In Find Contributions, check some entries. At Actions select Thank-you letter print or email. I put tokens ...
2
votes
1answer
164 views

Custom date field formatting with smarty

I'm trying to format a custom date field using smarty to send emails. What I want is to have the day of the week included, as "Wednesday, April 18, 2018". It seems that this should work: {contact....
2
votes
1answer
145 views

Smarty code not working

Writing as a self-answered question since it may help others... I am adding smarty code to a mail template. Including: {capture assign=designation}{contribution.contribution_source}{/capture} Later ...
2
votes
2answers
180 views

Is there a way to access [civicrm.files] from smarty?

I'd like to replace the default logo in my email templates ({$resourceBase}/i/civi99.png) with a URL that points to a different location where the custom logo won't be overwritten by updates. I can do ...
2
votes
1answer
153 views

Scheduled Reminder Email is Empty

We are using CiviCRM 4.6 on a live site we built with WordPress 4.6.1. We ran into the problem explained below. Any help is much appreciated. I have set up a scheduled reminder to send reminder ...
2
votes
1answer
888 views

How to get php $_SESSION variable inside a template

I am setting $_SESSION variable inside a payment response file and need this to display on Thank you page. Somehow nothing seems to work so far. Tried following things: $_SESSION['test'] = 'Hello ...
2
votes
2answers
83 views

Search Custom Template Directory first when using Smarty {include}

I'm sure this is easy but the answer has escaped me. On a drupal install CiviCRM is installed at: /webtree/mysite/htdocs/sites/www.mysite/modules/civicrm I have a Custom Template File directory set ...
2
votes
1answer
68 views

Add 'Non-deductible amount' to Contribution Receipt template

I am trying to add the non-deductible amount to my Automatic Contribution receipt but it is not printing the value. Any tips? I am using Civicrm 4.6.19 with Drupal 7 <tr> <td {$...
2
votes
1answer
230 views

How do I use custom Smarty functions in a Form?

The "Extending Smarty" page at http://wiki.civicrm.org/confluence/display/CRMDOC/Extending+Smarty gives instructions for writing custom php functions and calling them from Smarty templates used in ...
2
votes
2answers
1k views

How do I pass a variable to a smarty template?

Big picture: I'm working on a module that will display view-only custom data on a specific contribution page. Please understand, if you're not aware of this already, view-only custom data is not ...
2
votes
1answer
105 views

How to prevent Smarty secure_mode activation?

I hope my silly question will get answers from some of you... I'm just trying to send an email using smarty basics functions such as using {php} tags and playing php in smarty tags {if strstr($email, ...
2
votes
1answer
32 views

failed to open stream after PHP upgrade to 7.3

Started getting this error on some Civi pages after upgrading PHP to 7.3 on server running php-fpm and nginx. Works fine after restarting php-fpm but need to restart every morning to get around ...
2
votes
1answer
40 views

Smarty with CiviRules

I have a template with Smarty strings. If I send the email from inside CiviCRM, Smarty works fine (it shows "Cher Guillaume"): If I send the same template using a CiviRule, it doesn't work: ...
2
votes
2answers
218 views

White screen in 4.7.12

I note with the 4.7.12 version of the difficulties of implementation, particularly with queries that only lead to blank pages. Track errors in apache located abnormalities in smarty. I returned to ...
2
votes
1answer
197 views

Contribution confirmation page is blank

I have created a Member Sign-Up form that goes to a Contribution page with three price sets (one is always hidden with JS, so two appear). Under the Contribution Page's settings, "Use a confirmation ...
2
votes
0answers
163 views

What does undefined extension class 'Smarty_Internal_Method_Assign_By_Ref' Mean?

The new installation of CIVI works. LAMP server, shared hosting, PHP 7.2, Joomla! 3.9, etc. When I click to go to configuration checklist, I get the error: undefined extension class '...
2
votes
0answers
51 views

Can I include a message template within a message template [duplicate]

I know I can use {include } smarty function, can I also use that in message templates so we can have a generic template part that belongs to all other templates? We want to use this for PDF templates
1
vote
2answers
170 views

How to use Smarty for change greetings for French?

I need to adapt Greetings in order to fit to French (which has a feminine and masculine for "Dear"). I read on the forum that I should use Smarty and read the short documentation (CiviCRM ...
1
vote
2answers
47 views

How to include smarty script with mosaico email

I used to use a name personalisation in civimail with smarty script... {capture assign=nickname}{contact.nick_name}{/capture} Dear {if $nickname}{contact.nick_name}{else}{contact.sort_name}{/if} I ...
1
vote
3answers
2k views

If statement involving “is not empty” in smarty template?

How do I do this in a Smarty template: If {contact.supplemental_address_1} is not empty then {contact.supplemental_address_1}
1
vote
2answers
27 views

Smarty contribution summary works on one site, but not another on the same server

I have burned hours on this and feel at a wall. Would appreciate some fresh eyes to shed light on new avenues of exploration. I am using "find Contributions" to generate a list of ...
1
vote
1answer
53 views

How to use Contact name if nickname is not present in bulk mail?

I need to send an email with Nickname as first preference, if that not present then use Contact name. Cant figure out what token to use? I have tried this but seems not rendering correctly in email: ...
1
vote
1answer
88 views

Smarty Template CMS-agnostic URL

Please can someone remind me how to create a CMS-safe URL in Smarty Templates? Thanks
1
vote
1answer
76 views

$participant_status_id shows previous value in email template

Using version 4.6.9 on Drupal 7. I'm working on a revision to our email template for event registrants, and in our environment, it's important to distinguish between individuals who are awaiting ...
1
vote
1answer
114 views

How to include price field data in a Contribution Thank You letter

We have a need to display price field information in a contribution Thank You letter. As the token system can't handle the price set data, I've pulled the relevant Smarty code from the receipt ...