Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions

Site Title in Email Template


Reply

3 Posts   307 Views

Avatar
merrick_sd

21 January 2014 at 4:44am Community Member, 95 Posts

© $SiteConfig.Title $LastEdited.Format(Y) - All rights reserved

When I use the above my QuickEnquiryEmail.ss template it doesn't show up?

$SiteConfig.Title and $LastEdited.Format(Y) render in a Page.ss template.

My $emaildata is showing up fine in the generated email

if ($QuickEnquiry->write()) {
if ($mailfrom && $mailto) {

$emaildata = array(
'ContactName' => $data['Name'],
'ContactNumber' => $data['ContactTel'],
'ContactEmail' => $data['Email'],
'Comments' => str_replace("\n", "<br>", $data['Comments'])
);

$From = $mailfrom;
$To = $mailto;

$Subject = $mailsubject;    
$email = new Email($From, $To, $Subject);
$email->setTemplate('QuickEnquiryEmail');
$email->populateTemplate($emaildata);
$email->send();

Attached Files
Avatar
kinglozzer

22 January 2014 at 12:38am (Last edited: 22 January 2014 10:09pm), Community Member, 146 Posts

Hi,

SiteConfig isn't added to templates by default - it's added via ContentController->SiteConfig() for pages. To add it to emails you can add an array key to your $emaildata array:

$emaildata = array(
'ContactName' => $data['Name'],
'ContactNumber' => $data['ContactTel'],
'ContactEmail' => $data['Email'],
'Comments' => str_replace("\n", "<br>", $data['Comments']),
'SiteConfig' => SiteConfig::current_site_config()
);

Loz

Avatar
merrick_sd

22 January 2014 at 1:36am Community Member, 95 Posts

many thanks Loz

That worked perfectly.