Skip to content
Snippets Groups Projects
  1. Jan 22, 2014
  2. Jan 15, 2014
  3. Jan 02, 2014
  4. Nov 18, 2013
  5. Nov 13, 2013
  6. Nov 04, 2013
  7. Nov 02, 2013
  8. Oct 18, 2013
  9. Oct 09, 2013
    • Olaf Buddenhagen's avatar
      Process greeting templates with Smarty · 73d64eb6
      Olaf Buddenhagen authored
      When expanding `email_greeting`, `postal_greeting`, and `addressee`
      templates, after substituting the CiviCRM tokens, pass the result
      through Smarty.
      
      This way it becomes possible to include conditionals (or other types of
      fancy processing) in greeting templates. Example:
      
        {capture assign=style}{contact.communication_style}{/capture}
        {capture assign=prefix}{contact.individual_prefix}{/capture}
        {if $style=="Familiar"}
          {if $prefix=="Frau"}
            Liebe
          {elseif $prefix=="Herr"}
            Lieber
          {else}
            Liebe/r
          {/if}
          {contact.first_name}
        {else}
          {if $prefix=="Frau"}
            Liebe Frau
          {elseif $prefix=="Herr"}
            Lieber Herr
          {else}
            Liebe/r Herr oder Frau
          {/if}
          {contact.formal_title} {contact.last_name}
        {/if}
      
      The major limitation of this approach is that the `label` field -- where
      the actual greeting templates are stored -- is limited to 255
      characters. (So the above example wouldn't actually work without some
      trickery to make it shorter...) Not sure how to address this problem.
      
      We are wondering whether we should hide this feature behind a config
      option, like it is done for Mailings? I'm not sure this is really
      necessary here, as the Smarty processing shouldn't be in anyone's way
      when unused. The only possible downside is that templates with syntax
      errors might produce somewhat obscure warnings or errors in some cases.
      However, the greeting templates are generally only set up during the
      implementation phase, and never touched by mortal users -- just like
      system workflow message templates, which use Smarty unconditionally as
      well. Also, it feels wrong to hide such useful functionality behind some
      obscure option...
      
      To allow for proper Smarty escaping, this patch needs to introduce some
      small changes to the way contact tokens are processed in the greetings.
      These shouldn't affect other callers.
      
      To avoid code duplication, a new function is introduced for the template
      processing (tokens+Smarty), adding another layer of indirection. This
      could be avoided, if replaceGreetingTokens() wasn't used in other
      contexts too. (Which I believe is a misunderstanding: I'm pretty sure
      the function was only meant for *generating* the greeting texts, by
      replacing tokens in the greeting templates when saving a contact record;
      and not for replacing greeting tokens in message templates -- the latter
      should be handled just fine along with the other contact tokens...)
      73d64eb6
  10. Oct 07, 2013
  11. Sep 12, 2013
  12. Aug 15, 2013
  13. Jul 23, 2013
  14. May 17, 2013
  15. May 16, 2013
  16. Apr 28, 2013
  17. Apr 16, 2013
  18. Apr 15, 2013
  19. Mar 30, 2013
  20. Mar 23, 2013
  21. Mar 15, 2013
  22. Mar 13, 2013
  23. Mar 12, 2013
  24. Mar 11, 2013
  25. Mar 10, 2013
  26. Mar 05, 2013
Loading