As you’ve realized Smarty can be used to more than just site templates. You can set up templates for almost anything, for example e-mails. When you do this you have to decide on an approach, and I’ll cover three of them here.
adUnit = document.getElementById("google-ads-HGWb");google_ad_client = "ca-pub-2901355957576730";adUnit = document.getElementById("google-ads-HGWb");adWidth = adUnit.offsetWidth;if ( adWidth >= 999999 ) {/* GETTING THE FIRST IF OUT OF THE WAY */ } else if ( adWidth >= 336 ) {if (document.querySelectorAll(".ad_unit").length > 3 ) {google_ad_slot = "0";adUnit.style.display = "none";} else {google_ad_slot = "7795804991";google_ad_width = 336;google_ad_height = 280;adUnit.style.cssFloat = "";adUnit.style.styleFloat = "";adUnit.style.margin = "";adUnit.style.textAlign = "";adcount = document.querySelectorAll(".ad_unit").length;tag = "ad_unit_336x280_"+adcount;adUnit.className = adUnit.className + " ad_unit " + tag;}} else {google_ad_slot = "0";adUnit.style.display = "none";}Simple and straightforward
You can see this approach in the Smarty manual. The template simply states the message body, and if you have multiple bodies, say one in plain text and one in HTML, you can do like this.
mail.text.tpl:
Hi {$name},
You've got mail!
mail.html.tpl:
// HTML-header here
<body>
<h1>Hi {$name},</h1>
<p>You've got mail!</p>
</body>
Now you can simply fetch your two versions of the mail body and use them with your PHP code to send mails. The benefit here is that you keep a good abstraction, the person who makes the mail templates does not have to care about hos the mail is sent. A drawback is that you can’t store all information for this e-mail in one place; where do you store the subject?
adUnit = document.getElementById("google-ads-ZNiT");google_ad_client = "ca-pub-2901355957576730";adUnit = document.getElementById("google-ads-ZNiT");adWidth = adUnit.offsetWidth;if ( adWidth >= 999999 ) {/* GETTING THE FIRST IF OUT OF THE WAY */ } else if ( adWidth >= 336 ) {if (document.querySelectorAll(".ad_unit").length > 3 ) {google_ad_slot = "0";adUnit.style.display = "none";} else {google_ad_slot = "7795804991";google_ad_width = 336;google_ad_height = 280;adUnit.style.cssFloat = "";adUnit.style.styleFloat = "";adUnit.style.margin = "";adUnit.style.textAlign = "";adcount = document.querySelectorAll(".ad_unit").length;tag = "ad_unit_336x280_"+adcount;adUnit.className = adUnit.className + " ad_unit " + tag;}} else {google_ad_slot = "0";adUnit.style.display = "none";}The advanced solution
The advanced solution creates just one template containing all data needed for the e-mail message. Your template could look like this:
gotmail.mail.tpl:
Date: {$mail.date|date_format:"%a, %d %b %Y %H:%M:%S %z"}
From: "{$sender.name}" <{$sender.email}>
To: "{$recipient.name}" <{$recipient.email}>
Subject: New mail
Hi {$recipient.name},
You've got mail!
Here you just fetch the mail data and sends it. The benefit is that you store all data related to the e-mail at the same place. The drawbacks are that this method needs extra parsing to work with the built-in PHP mail() function and the abstraction is poor since the person creating the template now has to know how to enter all mail headers as well.
adUnit = document.getElementById("google-ads-QVPZ");google_ad_client = "ca-pub-2901355957576730";adUnit = document.getElementById("google-ads-QVPZ");adWidth = adUnit.offsetWidth;if ( adWidth >= 999999 ) {/* GETTING THE FIRST IF OUT OF THE WAY */ } else if ( adWidth >= 336 ) {if (document.querySelectorAll(".ad_unit").length > 3 ) {google_ad_slot = "0";adUnit.style.display = "none";} else {google_ad_slot = "7795804991";google_ad_width = 336;google_ad_height = 280;adUnit.style.cssFloat = "";adUnit.style.styleFloat = "";adUnit.style.margin = "";adUnit.style.textAlign = "";adcount = document.querySelectorAll(".ad_unit").length;tag = "ad_unit_336x280_"+adcount;adUnit.className = adUnit.className + " ad_unit " + tag;}} else {google_ad_slot = "0";adUnit.style.display = "none";}Best of all?
In this version you get the benefits from the two previous versions, eleminating the drawbacks. Here we can store all information about the e-mail in the template and we can still use them when sending the e-mail using PHP. Consider this template:
gotmail.mail.tpl:
Hi {$name},
You've got mail!
{assign var="subject" value="New mail"}
Now you can, as in the simple version, fetch the template to get the body text and then use the get_template_vars() Smarty method to get the subject from the template. Just apply some more Smarty tweaking using the built-in {capture} function or simply {insert} the templates from the first example to get a multi-body message in just one template file.
The code above should be considered as proof-of-concept or pseudo code, there are a few problems not solved in the examples above.