Answers.Body: <p>CiviCRM v5.48.1 is using Smarty v2.6, and  based on Demerit response above, it appears that Smarty v2 does not support arrays.</p>
  <p>I am not sure if Smarty v2 (in any form) never supported arrays, or if it is just the implementation in CiviCRM that does not support arrays.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-19T19:17:14.223Z
Answers.LastActivityDate: 2022-05-19T19:17:14.223Z
Answers.UserDisplayName: jsherk
Answers.Body: <p>If you don't care about line-items and are just using the financial type at the contribution level, you should be able to use grouping by financial type as described here, using table cell: <a href="https://docs.civicrm.org/user/en/latest/contributions/manual-receipts-and-thank-yous/#grouped-contribution-thank-you-letters" rel="nofollow noreferrer">https://docs.civicrm.org/user/en/latest/contributions/manual-receipts-and-thank-yous/#grouped-contribution-thank-you-letters</a></p>
  <p>Otherwise I don't think you can do arrays in smarty and the functions that might allow working around it will give a security error. But you could make a custom token in php.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-16T22:24:09.430Z
Answers.Text: So are you saying that arrays in Smarty are disabled in CiviCRM for security purposes? It's really irrelevent what I am trying to do besides create and use an array in Smarty in the Thank You message template. So if arrays just plain do not work, then that would be good information to mention somewhere in the docs so that others do not waste hours of their time trying to figure out why its not working.
Answers.UserDisplayName: jsherk
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-16T22:46:41.137Z
Answers.Text: Smarty v2 doesn't let you create arrays directly (v3 does). Smarty v2 does have things like `|explode` to call arbitrary php functions but those are disabled for security reasons.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-17T02:05:33.143Z
Answers.Text: It looks like current version of CiviCRM is using Smarty v2.6 so I guess no arrays then :(   Thank you for clarifying
Answers.UserDisplayName: jsherk
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-16T16:39:08.600Z
Answers.LastActivityDate: 2022-05-16T16:39:08.600Z
Answers.UserDisplayName: Demerit
Body: <p>I have Smarty enabled in settings file (on WordPress), and I am able to successfully use Smarty in Thank You letter template as long as I am using regular variables (non-arrays).</p>
  <p>As soon as I try to create an array, I am unable to get it to work. Here are some things I have tried...</p>
  <p>These simply display 1</p>
  <pre><code>&lt;!--
  {assign var=&quot;test&quot; value=[111,222,333]}
  --&gt;
  &lt;p&gt;{$test[2]}&lt;/p&gt;
  
  &lt;!--
  {assign var=&quot;test&quot; value=[111,222,333]}
  --&gt;
  &lt;p&gt;{$test.2}&lt;/p&gt;
  </code></pre>
  <p>These create an error:</p>
  <pre><code>&lt;!--
  {assign var=&quot;test&quot; value=['y'=&gt;'yellow','b'=&gt;'blue']} 
  --&gt;
  &lt;p&gt;{$test[y]}&lt;/p&gt;
  
  &lt;!--
  {assign var=&quot;test&quot; value=['y'=&gt;'yellow','b'=&gt;'blue']} 
  --&gt;
  &lt;p&gt;{$test.y}&lt;/p&gt;
  </code></pre>
  <p>EDIT: Just to add some more details on what I am doing... I am going to Find Contributions and then selecting All Records and then choosing Thank You Letters from the Actions drop down. I can successfully print a letter with ALL their contributions listed (each one individually), and I can successfully print a letter with a summary only Tax Deductible and/or Non Tax Deductible contributions. What I want to do is calculate a total for each Financial Type... I need to create an array in smarty in order add the total for each Financial Type seperately so I can then print a letter with a summary by Financial Type only. I am basing my solution on Iowa Boy answer from this thread: <a href="https://civicrm.stackexchange.com/questions/41120/how-to-print-usa-tax-receipt-to-individuals">How to print USA tax receipt to individuals?</a></p>
  <p>But regardless of my use case, I can not seem to get arrays in Smarty to work properly.</p>
  <p>EDIT: So apparently Smarty v2 (currently the version used by CiviCRM) does NOT let you create or work with arrays.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-16T12:59:04.260Z
Comments.Text: Just a suggestion, but it might be helpful for others if you share the specific Civi use case you're trying to resolve by using arrays in the templates?
Comments.UserDisplayName: Lesley Carter - BackOffice
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-16T16:32:40.120Z
Comments.Text: @LesleyCarter-BackOffice Okay, I have added more details.
Comments.UserDisplayName: jsherk
Tags: <wordpress><civimail><message-templates><smarty>
Title: Smarty arrays in message template for Thank You letters
ThreadText: # Smarty arrays in message template for Thank You letters
  
  (Asked by: username_0 on 2022-05-15)
  
  I have Smarty enabled in settings file (on WordPress), and I am able to successfully use Smarty in Thank You letter template as long as I am using regular variables (non-arrays).
  As soon as I try to create an array, I am unable to get it to work. Here are some things I have tried...
  These simply display 1
  
  {$test[2]}
  
  
  {$test.2}
  
  These create an error:
  
  {$test[y]}
  
  
  {$test.y}
  
  EDIT: Just to add some more details on what I am doing... I am going to Find Contributions and then selecting All Records and then choosing Thank You Letters from the Actions drop down. I can successfully print a letter with ALL their contributions listed (each one individually), and I can successfully print a letter with a summary only Tax Deductible and/or Non Tax Deductible contributions. What I want to do is calculate a total for each Financial Type... I need to create an array in smarty in order add the total for each Financial Type seperately so I can then print a letter with a summary by Financial Type only. I am basing my solution on Iowa Boy answer from this thread: How to print USA tax receipt to individuals?
  But regardless of my use case, I can not seem to get arrays in Smarty to work properly.
  EDIT: So apparently Smarty v2 (currently the version used by CiviCRM) does NOT let you create or work with arrays.
  
  **Tags:** wordpress, civimail, message-templates, smarty
  
  > **Comments:**
  > **username_1**: Just a suggestion, but it might be helpful for others if you share the specific Civi use case you're trying to resolve by using arrays in the templates?  
  > **username_0**: @LesleyCarter-BackOffice Okay, I have added more details.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2022-05-19. Score: 0 | Accepted answer
  
  CiviCRM v5.48.1 is using Smarty v2.6, and based on username_2 response above, it appears that Smarty v2 does not support arrays.
  
  I am not sure if Smarty v2 (in any form) never supported arrays, or if it is just the implementation in CiviCRM that does not support arrays.
  
  
  ---
  
  ### Answer by username_2 on 2022-05-16. Score: 0
  
  If you don't care about line-items and are just using the financial type at the contribution level, you should be able to use grouping by financial type as described here, using table cell: <https://docs.civicrm.org/user/en/latest/contributions/manual-receipts-and-thank-yous/#grouped-contribution-thank-you-letters>
  
  Otherwise I don't think you can do arrays in smarty and the functions that might allow working around it will give a security error. But you could make a custom token in php.
  
  > **Comments:**
  > **username_0**: So are you saying that arrays in Smarty are disabled in CiviCRM for security purposes? It's really irrelevent what I am trying to do besides create and use an array in Smarty in the Thank You message template. So if arrays just plain do not work, then that would be good information to mention somewhere in the docs so that others do not waste hours of their time trying to figure out why its not working.  
  > **username_2**: Smarty v2 doesn't let you create arrays directly (v3 does). Smarty v2 does have things like `|explode` to call arbitrary php functions but those are disabled for security reasons.  
  > **username_0**: It looks like current version of CiviCRM is using Smarty v2.6 so I guess no arrays then :(   Thank you for clarifying  
  
  ---
  
  