Search

A new extension, "Email Template Manager" is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

1. What's this?

Using this extension is it possible to let Symphony send pretty emails using XSLT.
Currently only S2.2.1 is supported.

2. Understanding the basics

Before using this extension, you should be familiar with the Symphony CMS. If you are not comfortable with datasources, events and parameters, please read the Symphony docs first.

2.1 Templates & layouts

Templates created by this extension are similar to traditional Symphony pages. Just like with normal pages, you can attach datasources, whose xml you can process using XSLT.

However, there are a few differences, too. Most emails will consist of two layouts: HTML and Plain. Every template created by the ETM has the option to select one or two layouts. For each layout, you will be able to set an XSLT template.

Warning: although it is possible, sending HTML-only templates is not recommended!

2.2 Subject, recipients and reply-to

The subject and reply-to settings in the config panel can contain XpPath and parameters. If your XPath returns more than one piece of data, only the first result is used - you can not have more than one subject.

For the recipients field, on the other hand, you can select more than one recipient with a single piece of XPath. You can use the Name <email@domain.com>, username, <email@domain.com> and "Name" <email@domain.com> syntaxes. Also, you can mix sources by combining queries with a comma: username, email@domain.com, {/data/recipients/entry/email} will create a valid list.

Warning: it is not possible to mix the parameters and xpath syntax in one query: {/data/$param} will not work

2.3 Parameters (event filters only!)

If you are using filters, the ETM will automatically add a few parameters that you can use to filter your datasources:

  • $etm-entry-id will contain the id of the entry inserted by the event. You can use this parameter to filter a datasource and to email the data entered by the user. We will see this in action in the Contact Form in the Tutorials section of this manual.
  • $etm-recipient will contain the email address of the recipient of the email. If you are sending to more than one person, the ETM will loop over your recipients, and set this value for every email. Again, you will be able to filter your datasources with this parameter to include more information about the recipient.

Email Template Manager updated to version 1.0 on 15th of March 2011

Ooh this looks exciting. While this provides a UI for compiling the emails, does it provide a UI for attaching/triggering the emails (e.g. attached to an event)? Or does the developer always have to write PHP into a custom event?

It is very exciting indeed. Especially building the content in the backend (instead of using Symphony pages) is a fantastic achievment. This is why the rewrite of my Email Newsletters extension is supposed to use the Email Template Manager.

The second exiting thing is how backend pages are generated in this extension!

But, at least at the moment, there is no "auto-generating" of email events or event filters. That shouldn't be a big deal for a developer though, because the API is rather simple... I guess Huib can say more about this.

@Nick: yes, at this moment, the only way to get the email-templates is by using the API.

The reason for this is because I wanted to abstract only the templates, to be used in other extensions. If there is the need to auto generate filters, I might look into it for a future release.

@Nick: I have added the event filter possibilities. It is not yet 100% completed (documentation and better debugging needs to be done), but I have sent the first functional emails using it today.

A more extended writeup will follow as soon as I have the time.

Email Template Manager updated to version 2.0beta on 1st of April 2011

What's new

  • Support for Event Filters
  • Better debugging / previewing
  • A lot of bugfixes and small improvents

Updating from a previous version

Right now, updating isn't as easy as it could be. Because of a namechange (Email Templates to Email Template Manager) quite a lot has changed.

You will get the best results by backing up your installed templates (if any), uninstalling / deleting your old installation and reinstalling this version.

Email Template Manager updated to version 2.0 on 2nd of April 2011

I just posted an issue: I get a warning when trying to create a new email template.

Thanks, that fixed it. So, now I can create the template. But I can't send the email. I've posted another issue: #2: Error on submitting event: null parameter for ksort().

The reason this didn't work was because you haven't specified any settings (recipients) for the event.

If you add an input field: <input type="hidden" name="etm[][recipients]" value="bauhouse" /> it should work.

In the meantime, I'll fix the error (it is supposed to give a more descriptive error message ;))

Edit: fixed

The error is handled properly now, and the entry is saved on submit, but the email is still not sent, even though I am using the username of a valid author:

<xsl:template match="/">
    <h1><xsl:value-of select="$page-title"/></h1>
    <form method="post" action="" enctype="multipart/form-data">
        <input name="MAX_FILE_SIZE" type="hidden" value="5242880" />
        <label>Title
            <input name="fields[title]" type="text" />
        </label>
        <input type="hidden" name="etm[][recipients]" value="stephen" />
        <input name="action[email-category-created]" type="submit" value="Submit" />
    </form>
</xsl:template>

The following event XML is returned:

<events>
    <member-login-info logged-in="yes" id="1" />
    <email-category-created id="745" result="success" type="created">
        <filter name="permission" status="passed" />
        <filter name="etm-category-created" status="failed">No recipients selected, can not send emails.</filter>
        <message>Entry created successfully.</message>
        <post-values>
            <title>Email</title>
        </post-values>
    </email-category-created>
</events>

Oops, forgive me, recipient should be used instead of recipients. So this makes it: <input type="hidden" name="etm[][recipient]" value="stephen" />

Thanks. I just figured that out. :-)

Now, I'm getting a Symphony Fatal Database Error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'stephen'')' at line 1 An error occurred while attempting to execute the following query SELECT SQL_CACHE email, first_name FROM sym_authors WHERE username IN (''stephen'')

Oops. That's my fault. I had tried single quotes around the recipient value and forgot to remove them.

The email sent successfully! Thanks, Huib.

Ah, good to hear!

However, the error that is showing up when you use quotes is no good, as it could potentially be used for bad things. I'll be fixing that, too..;)

Would I be able to handle this situation with the ETM extension? I would like to specify a different recipient (or set of recipients) depending on the values submitted in the form.

The best way would be the solution you proposed in your post. You could just set the value of $_POST['etm']['filter_name']['recipient'] based on the value of another field, as you said.

Also, you can always use other fields as a reference, so if you have a selectbox with values: sales, info, hr and support, and those are also Symphony users with an email address, something like this would also work: <input type="hidden" name="etm[][recipient]" value="fields[selectbox_name]" />.

Does that answer your question?

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details