Answers.Body: <p>There's also the <a href="https://github.com/josephlacey/com.jlacey.salutations" rel="nofollow noreferrer">Salutations</a> extension, which overlaps quite a bit with &quot;More Greetings&quot;.</p>
  <p>I have a significantly more feature-complete version of this extension in my Github, but because my version doesn't differentiate between addressee greetings and email/address greetings, it doesn't have a clean uninstall path.  One day I'd like to resolve that and merge my changes in.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-19T13:21:29.013Z
Answers.Text: Thank you. For your infomation: I already installed the "More Greetings" extension and it seems to work.
Answers.UserDisplayName: Pierre François
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-19T09:58:09.827Z
Answers.LastActivityDate: 2021-03-19T09:58:09.827Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>You should get an error about <code>Smarty error: (secure mode) accessing ... is not allowed</code>, although if you're using wordpress those messages just disappear unless you have php debugging turned on. But yes it won't let you use <code>{include}</code> that way.</p>
  <p>What might work is to make a little smarty plugin, like the <code>functionXXX</code> ones in CRM/Core/Smarty/plugins, and then use that, e.g. function.myGreeting.php, and then use it like <code>{myGreeting lang=$language}</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-17T20:35:41.110Z
Answers.Text: Interesting solution. Where do I find documentation for writing such a function, and where do I have to drop the corresponding file without losing it at every update of the system?
Answers.UserDisplayName: Pierre François
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-17T21:12:18.333Z
Answers.Text: Documentation is at https://www.smarty.net/docsv2/en/plugins.functions.tpl but I would just copy/paste one of the existing civi ones and edit it. For where to put it, it looks like civi will [find it](https://github.com/civicrm/civicrm-core/blob/ef22668791557/CRM/Core/Smarty.php#L106-L124) if you set a custom_php path at admin - system settings - directories and then put your smarty plugin file in a subfolder CRM/Core/Smarty/plugins under there. Or if you want to put it in an extension you might use hook_civicrm_config to add a path to CRM_Core_Smarty::singleton()->plugins_dir.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-17T15:09:37.753Z
Answers.LastActivityDate: 2021-03-17T15:09:37.753Z
Answers.UserDisplayName: Demerit
Answers.Body: <p>The length limit of the greetings syntax can be quite tricky, especially when using different languages with gender specific greetings.</p>
  <p>Luckily there is the extension <a href="https://github.com/systopia/de.systopia.moregreetings" rel="nofollow noreferrer">More Greetings</a> that provides</p>
  <ul>
  <li>additional greeting fields</li>
  <li>no length limit for syntax</li>
  <li>more possibilities such as using API calls in the syntax</li>
  <li>a basic syntax checker</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-17T15:36:48.963Z
Answers.Text: Interesting. The syntax checker also sounds like a more generally useful thing.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-17T20:34:04.230Z
Answers.Text: The extension is not listed in Home » CiviCRM » Administer CiviCRM » System Settings » Extensions. Where do I find a concise explanation for installing it from the downloaded ZIP file? Sorry for asking such a dumb question.
Answers.UserDisplayName: Pierre François
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-17T20:51:41.187Z
Answers.Text: OK, I found the answer to my question above: If you want to install a native CiviCRM extension which is not listed under Manage Extensions automatically: 1. Download the extension package from the download URL provided by the developer. 2. Unzip / untar the package and place it in your configured extensions directory. 3. If the package has been constructed properly - when you reload the Manage Extensions page the new extension should be listed with an Install link.
Answers.UserDisplayName: Pierre François
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-18T07:36:52.557Z
Answers.Text: We are in the process of getting the extension approved for automated distribution. This used to be complicated but there seems to be a better process now.
Answers.UserDisplayName: Fabian
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-18T14:08:59.240Z
Answers.Text: Once the extension is installed, I can see on each contact a list of new Greeting fields, but I don't understand how to build automatic Greetings that apply for all the contacts. It could be evident for people already knowing this extension, but in my eyes, there are gaping holes in the docs. The examples showing tpl code do not tell where to save these files.
Answers.UserDisplayName: Pierre François
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-19T07:35:22.633Z
Answers.Text: You should find the documentation follwoing the link above. The most important steps are:
  
  (1) Go to Administer -> Administration Console (under Communications section)
  You can decide how many additional greeting fields will be created by changing the number on the top.
  (2) Once the fields are created you can change the names in Administer -> Customize data and screens -> Custom fields.
  (3) Enter Smarty Logic  (examples can be found in the repository).
  (4) Clicking "Save & apply to all contacts" will update all of the additional greeting fields in CiviCRM.
Answers.UserDisplayName: Fabian
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-19T09:05:39.757Z
Answers.Text: The problem was step (1): in my configuration (under Drupal), the only menu entry I see with Administer » Administration console has no "Communication" section but only "System Status" and "Configuration Checklist". Is this a bug? The only way I found to enter to these settings was through the URL https://mysite.com/civicrm/admin/setting/moregreetings?reset=1
Answers.UserDisplayName: Pierre François
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-19T13:20:25.697Z
Answers.Text: Sounds like something is off, there should be many settings available...
Answers.UserDisplayName: Fabian
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-19T15:19:34.190Z
Answers.Text: I discovered a hidden feature in the drop down menus: when you click on Administer » Administration Console in the drop down menu without going to the submenus "System Status" or "Configuration Checklist", you land on a page called "Administer CiviCRM", which I never saw before: URL = https://mysite.com/civicrm/admin?reset=1. From there on, the explanation found in the docs starts to be understandable.
Answers.UserDisplayName: Pierre François
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-03-17T15:21:46.233Z
Answers.LastActivityDate: 2021-03-17T15:21:46.233Z
Answers.UserDisplayName: Fabian
Body: <p>When the content of the Email Greeting or the Postal Greeting field is getting too long, CiviCRM is no longer able to edit it through the GUI, what happened since I have activated Smarty and inserted large expressions.</p>
  <p>I want to have a standard greeting that works for every gender, language and style.</p>
  <p>This was working:</p>
  <pre><code>{capture assign=language}{contact.preferred_language}{/capture}{capture assign=prefix}{contact.individual_prefix}{/capture}{capture assign=style}{contact.communication_style}{/capture}
  {if $style == 'Formal'} {if $language == 'fr_FR'}Cher{elseif $language == 'nl_NL'}Geachte{else}Dear{/if}  {$prefix|replace:'De heer':'heer'|replace:'De heren':'heren'|lower} {contact.last_name}{else}{if $language == 'fr_FR'}Bonjour{elseif $language == 'nl_NL'}Dag{else}Dear{/if} {contact.first_name}{/if} 
  </code></pre>
  <p>but the expression is getting too long when I try to add a test about the gender. As a work around, I decided to put this expression inside a file to be included by Smarty with this expression:</p>
  <pre><code>{include file='/usr/share/drupal/sites/default/files/my-greeting.tpl'}
  </code></pre>
  <p>but this doesn't work: nothing is included. The file <code>/usr/share/drupal/sites/default/files/my-greeting.tpl</code> has the correct ownership and permissions.</p>
  <p>I would like to understand what I am doing wrong, and if it is possible to use this approach without opening a hole in the security of the system.</p>
  
Tags: <civimail><smarty>
Title: Insert file into greeting field with Smarty
ThreadText: # Insert file into greeting field with Smarty
  
  (Asked by: username_0 on 2021-03-17)
  
  When the content of the Email Greeting or the Postal Greeting field is getting too long, CiviCRM is no longer able to edit it through the GUI, what happened since I have activated Smarty and inserted large expressions.
  
  I want to have a standard greeting that works for every gender, language and style.
  
  This was working:
  
  ```
  {capture assign=language}{contact.preferred_language}{/capture}{capture assign=prefix}{contact.individual_prefix}{/capture}{capture assign=style}{contact.communication_style}{/capture}
  {if $style == 'Formal'} {if $language == 'fr_FR'}Cher{elseif $language == 'nl_NL'}Geachte{else}Dear{/if}  {$prefix|replace:'De heer':'heer'|replace:'De heren':'heren'|lower} {contact.last_name}{else}{if $language == 'fr_FR'}Bonjour{elseif $language == 'nl_NL'}Dag{else}Dear{/if} {contact.first_name}{/if} 
  
  ```
  
  but the expression is getting too long when I try to add a test about the gender. As a work around, I decided to put this expression inside a file to be included by Smarty with this expression:
  
  ```
  {include file='/usr/share/drupal/sites/default/files/my-greeting.tpl'}
  
  ```
  
  but this doesn't work: nothing is included. The file `/usr/share/drupal/sites/default/files/my-greeting.tpl` has the correct ownership and permissions.
  
  I would like to understand what I am doing wrong, and if it is possible to use this approach without opening a hole in the security of the system.
  
  **Tags:** civimail, smarty
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2021-03-17. Score: 4 | Accepted answer
  
  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](https://github.com/systopia/de.systopia.moregreetings) that provides
  
  * additional greeting fields
  * no length limit for syntax
  * more possibilities such as using API calls in the syntax
  * a basic syntax checker
  
  > **Comments:**
  > **username_2**: Interesting. The syntax checker also sounds like a more generally useful thing.  
  > **username_0**: The extension is not listed in Home » CiviCRM » Administer CiviCRM » System Settings » Extensions. Where do I find a concise explanation for installing it from the downloaded ZIP file? Sorry for asking such a dumb question.  
  > **username_0**: OK, I found the answer to my question above: If you want to install a native CiviCRM extension which is not listed under Manage Extensions automatically: 1. Download the extension package from the download URL provided by the developer. 2. Unzip / untar the package and place it in your configured extensions directory. 3. If the package has been constructed properly - when you reload the Manage Extensions page the new extension should be listed with an Install link.  
  > **username_3**: We are in the process of getting the extension approved for automated distribution. This used to be complicated but there seems to be a better process now.  
  > **username_0**: Once the extension is installed, I can see on each contact a list of new Greeting fields, but I don't understand how to build automatic Greetings that apply for all the contacts. It could be evident for people already knowing this extension, but in my eyes, there are gaping holes in the docs. The examples showing tpl code do not tell where to save these files.  
  > **username_3**: You should find the documentation follwoing the link above. The most important steps are:  (1) Go to Administer -> Administration Console (under Communications section) You can decide how many additional greeting fields will be created by changing the number on the top. (2) Once the fields are created you can change the names in Administer -> Customize data and screens -> Custom fields. (3) Enter Smarty Logic  (examples can be found in the repository). (4) Clicking "Save & apply to all contacts" will update all of the additional greeting fields in CiviCRM.  
  > **username_0**: The problem was step (1): in my configuration (under Drupal), the only menu entry I see with Administer » Administration console has no "Communication" section but only "System Status" and "Configuration Checklist". Is this a bug? The only way I found to enter to these settings was through the URL https://mysite.com/civicrm/admin/setting/moregreetings?reset=1  
  > **username_3**: Sounds like something is off, there should be many settings available...  
  > **username_0**: I discovered a hidden feature in the drop down menus: when you click on Administer » Administration Console in the drop down menu without going to the submenus "System Status" or "Configuration Checklist", you land on a page called "Administer CiviCRM", which I never saw before: URL = https://mysite.com/civicrm/admin?reset=1. From there on, the explanation found in the docs starts to be understandable.  
  
  ---
  
  ### Answer by username_1 on 2021-03-19. Score: 3
  
  There's also the [Salutations](https://github.com/josephlacey/com.jlacey.salutations) extension, which overlaps quite a bit with "More Greetings".
  
  I have a significantly more feature-complete version of this extension in my Github, but because my version doesn't differentiate between addressee greetings and email/address greetings, it doesn't have a clean uninstall path. One day I'd like to resolve that and merge my changes in.
  
  > **Comments:**
  > **username_0**: Thank you. For your infomation: I already installed the "More Greetings" extension and it seems to work.  
  
  ---
  
  ### Answer by username_2 on 2021-03-17. Score: 2
  
  You should get an error about `Smarty error: (secure mode) accessing ... is not allowed`, although if you're using wordpress those messages just disappear unless you have php debugging turned on. But yes it won't let you use `{include}` that way.
  
  What might work is to make a little smarty plugin, like the `functionXXX` ones in CRM/Core/Smarty/plugins, and then use that, e.g. function.myGreeting.php, and then use it like `{myGreeting lang=$language}`.
  
  > **Comments:**
  > **username_0**: Interesting solution. Where do I find documentation for writing such a function, and where do I have to drop the corresponding file without losing it at every update of the system?  
  > **username_2**: Documentation is at https://www.smarty.net/docsv2/en/plugins.functions.tpl but I would just copy/paste one of the existing civi ones and edit it. For where to put it, it looks like civi will [find it](https://github.com/civicrm/civicrm-core/blob/ef22668791557/CRM/Core/Smarty.php#L106-L124) if you set a custom_php path at admin - system settings - directories and then put your smarty plugin file in a subfolder CRM/Core/Smarty/plugins under there. Or if you want to put it in an extension you might use hook_civicrm_config to add a path to CRM_Core_Smarty::singleton()->plugins_dir.  
  
  ---
  
  