1

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 :)

5

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

  • 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} – Guillaume Sorel Aug 14 at 10:32
  • Cool, I hope you got it working? – Pradeep Nayak Aug 14 at 10:36
  • How do I use this code? Direct into the email template? I can't succeed to send email with this code in the body :( – Guillaume Sorel Aug 14 at 10:49
  • Yes, you can use this code in email template, make sure you switch off the editor when adding such smarty logics. – Pradeep Nayak Aug 14 at 10:51
  • Switch off editor? HOw do I do that? Sorry for my questions :( – Guillaume Sorel Aug 14 at 10:55
4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.