Answers.Body: <p>Thanks to @demerit for suggesting a way to capture the full Smarty error in the log. I discovered that I was not getting the entire error in the Apache log. Using <code>CRM_Core_Error::debug_log_message($error_msg);</code> I was able to capture the entire error which included the following useful line:</p>
  <pre><code> line 17]: [plugin] (secure mode) modifier 'number_format' is not allowed (Smarty_Compiler.class.php, line 1934)
  </code></pre>
  <p>Searching the web for that error revealed a <a href="https://civicrm.stackexchange.com/questions/9012/can-i-format-a-smarty-token-number-to-have-thousands-comma">post from Jan 2016</a> which showed that <code>number_format</code> is not supported, but one must use <code>crmNumberFormat</code> instead.</p>
  <p>Making this replacement solved the problem. It remains a mystery why <code>number_format</code> works in another of my CiviCRM installations when it seems to have been an issue since at least 2016. However, that is a problem for another day. For now I am happy to have resolved the issue on this installation.</p>
  <p>The corrected table is as follows:</p>
  <pre><code>&lt;table align=&quot;left&quot; border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;table&quot; style=&quot;margin-top:15px;&quot;&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;th&gt;Date&lt;/th&gt;
          &lt;th style=&quot;text-align:right;&quot;&gt;Amount&lt;/th&gt;
          &lt;th&gt;Method&lt;/th&gt;
          &lt;th&gt;Campaign&lt;/th&gt;
          &lt;th&gt;Note&lt;/th&gt;
      &lt;/tr&gt;
      &lt;!--
  {foreach from=$contributions item=contribution} {assign
  var=&quot;date&quot; value=$contribution.receive_date|date_format:&quot;%d %b
  %Y&quot;}
  --&gt;
      &lt;tr&gt;
          &lt;td&gt;{$date}&lt;/td&gt;
          &lt;td style=&quot;text-align:right;&quot;&gt;${$contribution.total_amount|crmNumberFormat:2:&quot;.&quot;:&quot;,&quot;}&lt;/td&gt;
          &lt;td&gt;{$contribution.payment_instrument}{if $contribution.check_number neq&quot;&quot;} - #{$contribution.check_number}{/if}&lt;/td&gt;
          &lt;td&gt;{$contribution.campaign}&lt;/td&gt;
          &lt;td&gt;{$contribution.contribution_source}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;!--
  {/foreach}
  
  --&gt;
      &lt;tr&gt;
          &lt;th&gt;2019 TOTAL&lt;/th&gt;
          &lt;th style=&quot;text-align:right;&quot;&gt;${$contribution_aggregate|crmNumberFormat:2:&quot;.&quot;:&quot;,&quot;}&lt;/th&gt;
          &lt;th&gt;&amp;nbsp;&lt;/th&gt;
          &lt;th&gt;&amp;nbsp;&lt;/th&gt;
          &lt;th&gt;&amp;nbsp;&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
  </code></pre>
  
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-28T18:20:12.723Z
Answers.LastActivityDate: 2020-12-28T18:20:12.723Z
Answers.UserDisplayName: kapn
Answers.Body: <p>I've recently burned a lot of time on what looks like the same problem. For me it was a the CK editor persisting in browser cache, refusing to pickup updated configuration (which looks right in your screenshot).</p>
  <p>Try different browser (or clean browser cache) and save the correct template again. Then test it. It should work.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-28T14:05:35.980Z
Answers.Text: A good thought, but unfortunately, I have already tried such measures over a number of days.
Answers.UserDisplayName: kapn
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-27T23:39:15.433Z
Answers.LastActivityDate: 2020-12-27T23:39:15.433Z
Answers.UserDisplayName: Marko
Body: <p>I have burned hours on this and feel at a wall. Would appreciate some fresh eyes to shed light on new avenues of exploration.</p>
  <p>I am using &quot;find Contributions&quot; to generate a list of contributions. I then choose &quot;Thank you letters&quot; and then choose the template I created.</p>
  <p>In the template I am using some Smarty code that I found online last year that summarizes contributions and creates a neat table:</p>
  <pre><code>{foreach from=$contributions item=contribution} 
       {assign var=&quot;date&quot; value=$contribution.receive_date|date_format:&quot;%d %b %Y&quot;}
      &lt;tr&gt;
          &lt;td&gt;{$date}&lt;/td&gt;
          &lt;td style=&quot;text-align:right;&quot;&gt;${$contribution.total_amount|number_format:2:&quot;.&quot;:&quot;,&quot;}&lt;/td&gt;
          &lt;td&gt;{$contribution.payment_instrument}{if $contribution.check_number neq&quot;&quot;} - #{$contribution.check_number}{/if}&lt;/td&gt;
          &lt;td&gt;{$contribution.campaign}&lt;/td&gt;
          &lt;td&gt;{$contribution.contribution_source}&lt;/td&gt;
      &lt;/tr&gt;
  {/foreach}
      &lt;tr&gt;
          &lt;th&gt;2020 TOTAL&lt;/th&gt;
          &lt;th style=&quot;text-align:right;&quot;&gt;${$contribution_aggregate|number_format:2:&quot;.&quot;:&quot;,&quot;}&lt;/th&gt;
          &lt;th&gt; &lt;/th&gt;
          &lt;th&gt; &lt;/th&gt;
          &lt;th&gt; &lt;/th&gt;
      &lt;/tr&gt;
  </code></pre>
  <p>It works great on one site producing a neat table:
  <a href="https://i.sstatic.net/P5fPC.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/P5fPC.png" alt="table output" /></a></p>
  <p>However, on another site on the same server, I get &quot;There has been a critical error on this website. Please check your site admin email inbox for instructions.&quot;</p>
  <p>Checking the Apache error log I find a somewhat non-specific error:</p>
  <pre><code>[Wed Dec 23 13:51:44.466136 2020] [php7:error] [pid 31786] [client maskedIP:43002] PHP Fatal error:  Smarty error: [in string:&amp;lt;table align=&amp;quot;left&amp;quot; border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; cellspacing=&amp;quot;0&amp;quot; class=&amp;quot;table&amp;quot; style=&amp;quot;margin-top:15px;&amp;quot;&amp;gt;\r\n\t&amp;lt;tbody&amp;gt;\r\n\t\t&amp;lt;tr&amp;gt;\r\n\t\t\t&amp;lt;th&amp;gt;Date&amp;lt;/th&amp;gt;\r\n\t\t\t&amp;lt;th style=&amp;quot;text-align:right;&amp;quot;&amp;gt;Amount&amp;lt;/th&amp;gt;\r\n\t\t\t&amp;lt;th&amp;gt;Method&amp;lt;/th&amp;gt;\r\n\t\t\t&amp;lt;th&amp;gt;Campaign&amp;lt;/th&amp;gt;\r\n\t\t\t&amp;lt;th&amp;gt;Note&amp;lt;/th&amp;gt;\r\n\t\t&amp;lt;/tr&amp;gt;\r\n\t\t&amp;lt;!--\r\n    {foreach from=$contributions item=contribution} {assign\r\n    var=&amp;quot;date&amp;quot; value=$contribution.receive_date|date_format:&amp;quot;%d %b\r\n    %Y&amp;quot;}\r\n  --&amp;gt;\r\n\t\t&amp;lt;tr&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;{$date}&amp;lt;/td&amp;gt;\r\n\t\t\t&amp;lt;td style=&amp;quot;text-align:right;&amp;quot;&amp;gt;${$contribution.total_amount|number_format:2:&amp;quot;.&amp;quot;:&amp;quot;,&amp;quot;}&amp;lt;/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;{$contribution.payment_instrument}{if $contribution.check_number neq&amp;quot;&amp;quot;} - #{$contribution.check_number}{/if}&amp;lt;/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;{$contribution.campaign}&amp;lt;/td&amp;gt;\r\n\t\t\t&amp;lt;td&amp;gt;{$contribution.contri in /var/www/masked-url.org/wordpress/wp-content/plugins/civicrm/civicrm/packages/Smarty/Smarty.class.php on line 1100, referer: https://masked-url.org/wp-admin/admin.php?page=CiviCRM&amp;q=civicrm%2Fcontribute%2Fsearch&amp;_qf_PDFLetter_display=true&amp;qfKey=bd001d277ba51fe3447c1acb3c2bed4dceb754c89022040c362d62bb4e04b4b3_9738
  </code></pre>
  <p>I have disabled entities in the CKEditor on both sites:</p>
  <p><a href="https://i.sstatic.net/Qo8Ib.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Qo8Ib.png" alt="CKEditor settings" /></a></p>
  <p>I have ensured Smarty is enabled in message templates and the error log confirms that because the error is clearly Smarty related.</p>
  <p>I have literally cut-and-pasted the code from one site to the other and not changed it in any way.</p>
  <p>I am able to do a very simple test successfully by putting the following code into a template:</p>
  <pre><code>&lt;p&gt;{$smarty.now|date_format}&lt;/p&gt;
  &lt;p&gt;{$smarty.version}&lt;/p&gt;
  </code></pre>
  <p>I get valid output for that simple test on both sites:</p>
  <p><a href="https://i.sstatic.net/SEJUw.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/SEJUw.png" alt="enter image description here" /></a></p>
  <p>I have also tried writing other Smarty code, but have had no luck getting anything other than that basic case to work. Likely that has at least something to do with my limited Smarty experience.
  However, the first code I shared works just great on one site and fails on the other.</p>
  <p><strong>Site 1 (works):</strong>
  WordPress 5.6, PHP 7.3.22, CiviCRM 5.30.0, Smarty 2.6.31 (though this seems very old so I expect it has been the CiviCRM version for a long time)</p>
  <p><strong>Site 2 (doesn't work - error above):</strong>
  WordPress 5.6, PHP 7.3.22, CiviCRM 5.32.2, Smarty 2.6.31</p>
  <p>While the CiviCRM versions differ, I would hope that this is not a regression. It seems especially unlikely since the Smarty version has not changed.</p>
  <p>Hoping someone can shed light or offer other places to look for useful logs that might provide a clue.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-23T20:57:19.837Z
Comments.Text: Not an ideal option but I would suggest you to change CiviCRM version to 5.30.0 - Sometime different version do make big difference - Thanks
Comments.UserDisplayName: Ramesh - ARTECH Consultancy
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-23T21:51:27.357Z
Comments.Text: What I would do is add a line like `CRM_Core_Error::debug_log_message($error_msg);` just before line 1099 in packages/Smarty/Smarty.class.php and then you'll be able to see the full error and what it doesn't like by looking in ConfigAndLog.
Comments.UserDisplayName: Demerit
Tags: <civicontribute><message-templates><smarty>
Title: Smarty contribution summary works on one site, but not another on the same server
ThreadText: # Smarty contribution summary works on one site, but not another on the same server
  
  (Asked by: username_0 on 2020-12-23)
  
  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 contributions. I then choose "Thank you letters" and then choose the template I created.
  In the template I am using some Smarty code that I found online last year that summarizes contributions and creates a neat table:
  {foreach from=$contributions item=contribution} 
       {assign var="date" value=$contribution.receive_date|date_format:"%d %b %Y"}
      
          {$date}
          ${$contribution.total_amount|number_format:2:".":","}
          {$contribution.payment_instrument}{if $contribution.check_number neq""} - #{$contribution.check_number}{/if}
          {$contribution.campaign}
          {$contribution.contribution_source}
      
  {/foreach}
      
          2020 TOTAL
          ${$contribution_aggregate|number_format:2:".":","}
           
           
           
      
  
  It works great on one site producing a neat table:
  
  However, on another site on the same server, I get "There has been a critical error on this website. Please check your site admin email inbox for instructions."
  Checking the Apache error log I find a somewhat non-specific error:
  [Wed Dec 23 13:51:44.466136 2020] [php7:error] [pid 31786] [client maskedIP:43002] PHP Fatal error:  Smarty error: [in string:<table align="left" border="1" cellpadding="5" cellspacing="0" class="table" style="margin-top:15px;">\r\n\t<tbody>\r\n\t\t<tr>\r\n\t\t\t<th>Date</th>\r\n\t\t\t<th style="text-align:right;">Amount</th>\r\n\t\t\t<th>Method</th>\r\n\t\t\t<th>Campaign</th>\r\n\t\t\t<th>Note</th>\r\n\t\t</tr>\r\n\t\t<!--\r\n    {foreach from=$contributions item=contribution} {assign\r\n    var="date" value=$contribution.receive_date|date_format:"%d %b\r\n    %Y"}\r\n  -->\r\n\t\t<tr>\r\n\t\t\t<td>{$date}</td>\r\n\t\t\t<td style="text-align:right;">${$contribution.total_amount|number_format:2:".":","}</td>\r\n\t\t\t<td>{$contribution.payment_instrument}{if $contribution.check_number neq""} - #{$contribution.check_number}{/if}</td>\r\n\t\t\t<td>{$contribution.campaign}</td>\r\n\t\t\t<td>{$contribution.contri in /var/www/masked-url.org/wordpress/wp-content/plugins/civicrm/civicrm/packages/Smarty/Smarty.class.php on line 1100, referer: https://masked-url.org/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fcontribute%2Fsearch&_qf_PDFLetter_display=true&qfKey=bd001d277ba51fe3447c1acb3c2bed4dceb754c89022040c362d62bb4e04b4b3_9738
  
  I have disabled entities in the CKEditor on both sites:
  
  I have ensured Smarty is enabled in message templates and the error log confirms that because the error is clearly Smarty related.
  I have literally cut-and-pasted the code from one site to the other and not changed it in any way.
  I am able to do a very simple test successfully by putting the following code into a template:
  {$smarty.now|date_format}
  {$smarty.version}
  
  I get valid output for that simple test on both sites:
  
  I have also tried writing other Smarty code, but have had no luck getting anything other than that basic case to work. Likely that has at least something to do with my limited Smarty experience.
  However, the first code I shared works just great on one site and fails on the other.
  Site 1 (works):
  WordPress 5.6, PHP 7.3.22, CiviCRM 5.30.0, Smarty 2.6.31 (though this seems very old so I expect it has been the CiviCRM version for a long time)
  Site 2 (doesn't work - error above):
  WordPress 5.6, PHP 7.3.22, CiviCRM 5.32.2, Smarty 2.6.31
  While the CiviCRM versions differ, I would hope that this is not a regression. It seems especially unlikely since the Smarty version has not changed.
  Hoping someone can shed light or offer other places to look for useful logs that might provide a clue.
  
  **Tags:** civicontribute, message-templates, smarty
  
  > **Comments:**
  > **username_1**: Not an ideal option but I would suggest you to change CiviCRM version to 5.30.0 - Sometime different version do make big difference - Thanks  
  > **username_2**: What I would do is add a line like `CRM_Core_Error::debug_log_message($error_msg);` just before line 1099 in packages/Smarty/Smarty.class.php and then you'll be able to see the full error and what it doesn't like by looking in ConfigAndLog.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2020-12-28. Score: 2 | Accepted answer
  
  Thanks to @demerit for suggesting a way to capture the full Smarty error in the log. I discovered that I was not getting the entire error in the Apache log. Using CRM_Core_Error::debug_log_message($error_msg); I was able to capture the entire error which included the following useful line:
   line 17]: [plugin] (secure mode) modifier 'number_format' is not allowed (Smarty_Compiler.class.php, line 1934)
  
  Searching the web for that error revealed a post from Jan 2016 which showed that number_format is not supported, but one must use crmNumberFormat instead.
  Making this replacement solved the problem. It remains a mystery why number_format works in another of my CiviCRM installations when it seems to have been an issue since at least 2016. However, that is a problem for another day. For now I am happy to have resolved the issue on this installation.
  The corrected table is as follows:
  
  
      
          Date
          Amount
          Method
          Campaign
          Note
      
      
      
          {$date}
          ${$contribution.total_amount|crmNumberFormat:2:".":","}
          {$contribution.payment_instrument}{if $contribution.check_number neq""} - #{$contribution.check_number}{/if}
          {$contribution.campaign}
          {$contribution.contribution_source}
      
      
      
          2019 TOTAL
          ${$contribution_aggregate|crmNumberFormat:2:".":","}
  
  
  ---
  
  ### Answer by username_3 on 2020-12-27. Score: 1
  
  I've recently burned a lot of time on what looks like the same problem. For me it was a the CK editor persisting in browser cache, refusing to pickup updated configuration (which looks right in your screenshot).
  
  Try different browser (or clean browser cache) and save the correct template again. Then test it. It should work.
  
  > **Comments:**
  > **username_0**: A good thought, but unfortunately, I have already tried such measures over a number of days.  
  
  ---
  
  