Answers.Body: <p>Try below code</p>
  
  <pre><code>{capture assign=contact_gender}{contact.gender}{/capture}
  {if $contact_gender eq 'Female'}
    Chère {$first_name|default:Friend},
  {/if}
  </code></pre>
  
  <p>or</p>
  
  <pre><code>{capture assign=contact_gender}{contact.gender}{/capture}
  {assign var='contact_greeting' value='Dear'}
  {if $contact_gender eq 'Female'}
    {assign var='contact_greeting' value='Chère'}
  {/if}
  
  {$contact_greeting} {$first_name|default:Friend},
  </code></pre>
  
  <p>Cheers</p>
  
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-14T10:32:32.673Z
Answers.Text: Thanks Pradeep! I was trying something like : {capture assign=gender}{contact.gender}{/capture}
  {if $gender eq 'Homme'}
      Cher {$first_name},
  {elseif $gender eq 'Femme'}
      Chère {$first_name},
  {/if}
Answers.UserDisplayName: Guillaume Sorel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-14T10:36:17.413Z
Answers.Text: Cool, I hope you got it working?
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-14T10:49:36.520Z
Answers.Text: How do I use this code? Direct into the email template? I can't succeed to send email with this code in the body :(
Answers.UserDisplayName: Guillaume Sorel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-14T10:51:12.330Z
Answers.Text: Yes, you can use this code in email template, make sure you switch off the editor when adding such smarty logics.
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-14T10:55:59.280Z
Answers.Text: Switch off editor? HOw do I do that? Sorry for my questions :(
Answers.UserDisplayName: Guillaume Sorel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-14T11:10:05.880Z
Answers.Text: By clicking on the 'Source' of editor. It should on top left corner of the editor.
Answers.UserDisplayName: Pradeep Nayak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-22T14:05:03.080Z
Answers.Text: hit "Source" in the WYSIWYG.
Answers.UserDisplayName: Marsh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-14T09:44:44.087Z
Answers.LastActivityDate: 2019-08-14T09:44:44.087Z
Answers.UserDisplayName: Pradeep Nayak
Answers.Body: <p>Thanks to Pradeep's help I found the way:</p>
  
  <p>For my case, this is the code to use</p>
  
  <pre><code>{capture assign=gender}{contact.gender}{/capture}
  {if $gender eq 'Homme'} Cher {contact.first_name}, 
  {elseif $gender eq 'Femme'} Chère {contact.first_name}, 
  {/if}
  </code></pre>
  
  <p>I just needed to insert it where needed in the source of the email. FuzionFields was of a good help to find the correct string for the field Gender. It was also important to write <code>{contact.first_name}</code> and not <code>{first_name}</code> like writen in the documentation.</p>
  
  <p>To make Smarty work with CKeditor you'll also need to set this parameter using Pradeep's other answer: <a href="https://civicrm.stackexchange.com/questions/22082/how-to-deal-with-or-39-in-ckeditor/22618#22618">How to deal with &#39; or (&amp;#39;) in CKeditor</a></p>
  
  <p>I'm very happy to have this small but nice enhancement for our feminine members.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-17T10:06:15.173Z
Answers.Text: Don't forget that it doesn't work within Mosaico as Mosaico and Smarty are not compatible. Using a Mosaico template you have to find another way to personalize greetings :-(
Answers.UserDisplayName: Guillaume Sorel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-14T12:27:37.023Z
Answers.LastActivityDate: 2019-08-15T11:38:49.103Z
Answers.LastEditDate: 2019-08-15T11:38:49.103Z
Answers.UserDisplayName: Guillaume Sorel
Body: <p>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 (<a href="https://docs.civicrm.org/user/en/latest/common-workflows/tokens-and-mail-merge/#smarty" rel="nofollow noreferrer">CiviCRM documentation</a>) but I haven't understood how to use it :(</p>
  
  <p>Where should the following code come (once adapted of course)? In the email source or in the greetings settings?</p>
  
  <pre><code>{capture assign=first_name}{contact.first_name}{/capture}
  Dear {$first_name|default:Friend},
  {if $first_name}
    Hello, {$first_name}, how are you?
  {/if}
  </code></pre>
  
  <p>My second question is where do I set something like: </p>
  
  <pre><code>WHEN contact_gender IS female THEN contact_greeting IS Chère
  </code></pre>
  
  <p>Do I have to create any custom fields?</p>
  
  <p>Any help will be very appreciated :)</p>
  
Tags: <smarty>
Title: How to use Smarty for change greetings for French?
ThreadText: # How to use Smarty for change greetings for French?
  
  (Asked by: username_0 on 2019-08-14)
  
  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 documentation) but I haven't understood how to use it :(
  Where should the following code come (once adapted of course)? In the email source or in the greetings settings?
  {capture assign=first_name}{contact.first_name}{/capture}
  Dear {$first_name|default:Friend},
  {if $first_name}
    Hello, {$first_name}, how are you?
  {/if}
  
  My second question is where do I set something like: 
  WHEN contact_gender IS female THEN contact_greeting IS Chère
  
  Do I have to create any custom fields?
  Any help will be very appreciated :)
  
  **Tags:** smarty
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2019-08-14. Score: 4 | Accepted answer
  
  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 eq 'Femme'} Chère {contact.first_name}, 
  {/if}
  
  I just needed to insert it where needed in the source of the email. FuzionFields was of a good help to find the correct string for the field Gender. It was also important to write {contact.first_name} and not {first_name} like writen in the documentation.
  To make Smarty work with CKeditor you'll also need to set this parameter using Pradeep's other answer: How to deal with ' or (') in CKeditor
  I'm very happy to have this small but nice enhancement for our feminine members.
  
  > **Comments:**
  > **username_0**: Don't forget that it doesn't work within Mosaico as Mosaico and Smarty are not compatible. Using a Mosaico template you have to find another way to personalize greetings :-(  
  
  ---
  
  ### Answer by username_1 on 2019-08-14. Score: 4
  
  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.gender}{/capture}
  {assign var='contact_greeting' value='Dear'}
  {if $contact_gender eq 'Female'}
    {assign var='contact_greeting' value='Chère'}
  {/if}
  
  {$contact_greeting} {$first_name|default:Friend},
  
  Cheers
  Pradeep
  
  > **Comments:**
  > **username_0**: Thanks Pradeep! I was trying something like : {capture assign=gender}{contact.gender}{/capture} {if $gender eq 'Homme'}     Cher {$first_name}, {elseif $gender eq 'Femme'}     Chère {$first_name}, {/if}  
  > **username_1**: Cool, I hope you got it working?  
  > **username_0**: How do I use this code? Direct into the email template? I can't succeed to send email with this code in the body :(  
  > **username_1**: Yes, you can use this code in email template, make sure you switch off the editor when adding such smarty logics.  
  > **username_0**: Switch off editor? HOw do I do that? Sorry for my questions :(  
  > **username_1**: By clicking on the 'Source' of editor. It should on top left corner of the editor.  
  > **username_2**: hit "Source" in the WYSIWYG.  
  
  ---
  
  