10

Details

We would like to create a standard header and footer for our email templates. Rather than pasting the custom HTML in the top of each system email template we want to override, it would be better to define a header template, and a footer template, and then use smarty to {include} these templates.

Is this possible with CiviCRM?

Is there a reason CiviCRM doesn't have a single header/footer template by default? If not would this make a reasonable feature request?

2
  • Please note that the question is regarding System Workflow Messages and not CiviMail Messages. Aug 18, 2015 at 18:31
  • 1
    @John, not sure if you made any progress on this, but FYI on this forum post I just added: forum.civicrm.org/index.php?topic=37157.0
    – Laryn
    Apr 28, 2016 at 17:46

4 Answers 4

6
  1. I dont think CiviCRM does this by default

  2. However, I do think this is a good idea and makes sense to include it in core for non-civimail mailings (which already have a header/footer)

  3. Might want to modify the core mailing functions:

CRM_Core_BAO_MessageTemplate::sendTemplate

to add a default header / footer

  1. Might want to allow this to be overridden both at the system level, function level and via a hook
2
  • Sounds great, but might require a significant amount of work. I'm also hoping there might be a quicker solution which would allow me to just {include} custom templates in the short term. But this would be something we would be happy to work on in the future if time allows us to.
    – John
    Apr 9, 2015 at 17:26
  • Its a relatively easy,small and localized patch. You can reuse most of the code from the civimal code file Apr 9, 2015 at 22:27
1

I just want to clarify the basic functionality provided by CiviMail, since it may provide enough. CiviMail has separate functionality to manage headers and footers and templates. So a standard header and footer can be defined and used for several templates. At the time of configuring a mailing 1) the template if any is specified and then an instance (ie copy) of it can modified in the editor, and 2) the header if any and 3) the footer if any are also specified. If your main interest is in being able to separate managing the header and footer from all the templates that use them, this should be enough.

If you are more interested in pre-assigning for each template a specific header and footer, then a small extension could be developed that would allow the header and footer for a template to be specified when it is edited. Later when a mailing is being configured and a template is selected, those stored selections would be used to set the mailing's header and footer.

1
  • Thanks Joe. I'm particularly interested in the system-generated email message such as event confirmation emails, rather than the CiviMail templates.
    – John
    Apr 10, 2015 at 10:27
1

one option might be to create a custom token {template.header} and {template.footer} that generates the needed html. the way you implement that function can be to fetch the html from a template. Note that it probably means you can't have token within these templates, that might or might not be an issue for you

1

We've done this, unless I'm misunderstanding you.

I made an extension and put the required header code (in our case, a formatted address block) into a tpl in the templates/CRM/something directory. This included tokens etc. as it would have in the message template itself. Then in the message template I just used {include file=CRM/something/addressdate.tpl}.

This works fine for us, but I did encounter weird stuff to do with needing/not-needing the $ symbol on tokens. This seemed directly related to the use of an include file, as the same issues didn't arise if you put the same header code into the message template itself. That said we have a bunch of other extensions, and I never figured out the root cause, so ymmv.

3
  • Forgot to say it probably needs CIVICRM_MAIL_SMARTY enabled in civicrm.settings.php. May 22, 2015 at 13:12
  • Sorry, I was a bit confusing there. There's nothing to the extension other than this template - I just like to keep things organised :-) You could put the .tpl file into your custom templates directory and it'd be exactly the same Aug 12, 2015 at 18:33
  • I see - sorry. Got a bit confused that this was re: CiviMail but OP is specific about System Workflow Messages. Aug 18, 2015 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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