Alternate templates with Mail engine
I recently downloaded the excellent package Mail Engine from Tim’s blog. This package rocks. One issue I had was being able to have an alternate template for the newsletter im sending out. A newsletter template with minimal furniture would be ideal. However the current version of mail engine does not support alternate templates. So I did the following:
- Created newsletters doctype with one property umbracoNaviHide (true/false)
- Created newsletter doc type with one property with alias sourceNode and type content picker.
- Created a node of type newsletters in the root of the site
- Created a node of type newsletter in newsletters (step 3) and picked the document I wanted to email using the content picker
- Added XSLT macro called GetContentForEmail that i created which has the following code
<xsl:if test="$currentPage/data[@alias='sourceNode']!='' and umbraco.library:QueryForNode($currentPage/data[@alias='sourceNode'])"> <xsl:value-of select="umbraco.library:GetItem($currentPage/data[@alias='sourceNode'], 'bodyText')" disable-output-escaping="yes"/> </xsl:if>
- Created template for newsletter that uses macro from step 5 and in head tag added style tag with styles for formatting the page
I then sent this page as an email. Bascially now works like ultrasimple mailer used to.