Hot answers tagged

9 votes

Escaping quotes in ckeditor breaks smarty-syntax

Adding config.entities = false; to the ckeditor-config packages/ckeditor/config.js prevent ckeditor from escaping special characters. This avoids the issue with smarty-syntax. But I am not sure if ...
user avatar
  • 311
9 votes
Accepted

How to deal with ' or (') in CKeditor

You can turn off html encoding for CKeditor through UI (i.e >= 4.7) Navigate to Administer >> Customize Data and Screens >> Display preferences Scroll down until you see Configure CkEditor button. ...
user avatar
7 votes
Accepted

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

As I learned from @Nicholai in a previous (unrelated) thread, you can override these templates with some pretty easy logic to add something custom to a single page. For example: {if $...
user avatar
7 votes

How can I see the available tokens for message templates?

Insert {debug} into a message template then perform the relevant action (ie make an online contribution if you modified Contributions - Receipt (on-line)). The email sent will contain a list of all ...
user avatar
  • 3,440
6 votes
Accepted

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

I dont think CiviCRM does this by default However, I do think this is a good idea and makes sense to include it in core for non-civimail mailings (which already have a header/footer) Might want to ...
user avatar
  • 3,803
6 votes

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

You can run php inside smarty, you just need to include it within {php} tags. {php} $result = doSomethingCool(); $this->assign('coolStuff', $result); {/php} <div>Your social media ...
user avatar
  • 16.1k
6 votes
Accepted

How to set a id attribute to button?

I believe you cannot set id to a button using php however you can define your own class for the button and use JS to set the id for that class. Here is the snippet to add class for button $this->...
user avatar
6 votes
Accepted

SMARTY error with template

The styling needs to be wrapped in {literal}...{/literal} in the message template.
user avatar
  • 17.5k
5 votes

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

The civi provided modifier has a different name: crmNumberFormat moreover as per Paul-Tahoe analysis, smarty seems to be confused, so the trick is to assign the formatted value to a temporary ...
user avatar
  • 10.1k
5 votes
Accepted

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

Rather than smarty, JavaScript will do the trick. Those tabs are all separate pages, and you can load any CiviCRM page/form as a snippet instead. First, in your extension, use a hook to include the ...
user avatar
  • 7,337
5 votes

How to use Smarty for change greetings for French?

Try below code {capture assign=contact_gender}{contact.gender}{/capture} {if $contact_gender eq 'Female'} Chère {$first_name|default:Friend}, {/if} or {capture assign=contact_gender}{contact....
user avatar
5 votes
Accepted

Displaying custom contribution field in the online receipt

The smarty variables for online and offline may be different for Contribution ID. For offline {crmAPI var='rname' entity='Contribution' action='getvalue' return="custom_134" id=`$...
user avatar
4 votes

How can I see the available tokens for message templates?

You can insert the {debug} Smarty token into your template: http://forum.civicrm.org/index.php/topic,14845.msg63471.html#msg63471
user avatar
4 votes
Accepted

How can I see the available tokens for message templates?

use {debug output=html} To have a nice formatting in html email
user avatar
  • 118
4 votes

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

The template ​templates/​CRM/​Contact/​Page/​Inline/ContactName.tpl does not contain any custom fields. Instead of adding smartyDebug=1 in the url, which dumps variables in the main template, try ...
user avatar
  • 16.1k
4 votes

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

Since you are wanting to do more than just a "little bit" of php in your smarty template I would suggest this alternate approach: Implement a hook that fires when you want, such as ...
user avatar
  • 16.1k
4 votes
Accepted

Contribution Note Smarty Variable

I might be missing something but, the contribution.contribution_id variable you are referring as a standalone variable I believe is a token, I can't figure out what's the smarty variable for it but ...
user avatar
  • 2,301
4 votes
Accepted

Override TPL path dynamically

Use an extension's templates dir Creating a simple extension via civix provides a templates/ directory in the extension. This is searched before the default templates, so you can intercept and ...
user avatar
4 votes
Accepted

Custom Email Greeting token doesn't work

Any chance you don't have smarty enabled for civiMail so your capture-assigns and ifs aren't working in the mail? Try checking your civicrm.settings.php file and look for the line define( '...
user avatar
  • 1,489
4 votes

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

Don't think you have a direct variable to use in the template. Worth trying an extension to provide this? It can be done by simply writing something like below in your hook. function ...
user avatar
4 votes

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

You can use CiviCRM api through smarty to retrieve if membership is active for a contact. You can achieve this by Turn on CIVICRM_MAIL_SMARTY (set to TRUE or 1) in civicrm.settings.php add below api ...
user avatar
4 votes
Accepted

Custom date field formatting with smarty

Found the answer. The civi field token must be captured to a Smarty variable first: {capture assign=arr}{contact.custom_105}{/capture}{$arr|date_format:"%A, %B %e, %Y"}
user avatar
4 votes
Accepted

How to use Smarty for change greetings for French?

Thanks to Pradeep's help I found the way: For my case, this is the code to use {capture assign=gender}{contact.gender}{/capture} {if $gender eq 'Homme'} Cher {contact.first_name}, {elseif $gender ...
user avatar
4 votes
Accepted

Smarty only generating nulls from API calls

So, for posterity's sake, I wanted to share the answer I figured out. When I looked at the Source view of the email in CiviCRM, I realized that the code had pasted as <p>id:&nbsp;{contact....
user avatar
  • 81
4 votes
Accepted

Insert file into greeting field with Smarty

The length limit of the greetings syntax can be quite tricky, especially when using different languages with gender specific greetings. Luckily there is the extension More Greetings that provides ...
user avatar
  • 3,309
3 votes

How to get php $_SESSION variable inside a template

Try following: // php code; $_SESSION['test'] = 'Hello World'; // assign 'Hello World' to .tpl $this->assign('test', $_SESSION['test']); // use '{$test}' following in ...
user avatar
  • 483
3 votes
Accepted

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

It doesn't work because $lineItem is not set in the template, you'll have to loop thorough $contribtuions and use the API: {foreach from=$contributions item=contribution} {crmAPI var='result' entity='...
user avatar
  • 2,301
3 votes
Accepted

$participant_status_id shows previous value in email template

This was posted a while ago, but I thought I should post the solution I finally found to the problem (which still exists in my version 4.7.29 install) The solution to this problem was an API call. ...
user avatar
  • 133
3 votes

Scheduled Reminder Email is Empty

For anyone who may face this issue, it was finally fixed by WP Engine through adding an exception on the firewall for CiviCRM cron URL.
user avatar
3 votes
Accepted

Smarty and future proof code

Going forward, much of the Civi UI will be written in Angular. However at least 95% of the application uses Smarty and it's still a perfectly acceptable way to mark up a form or page. Depending on ...
user avatar
  • 16.1k

Only top scored, non community-wiki answers of a minimum length are eligible