Jump to:

3444 Posts in 1030 Topics by 871 members

Template Questions

SilverStripe Forums » Template Questions » Site Title in Email Template

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 290 Views
  • merrick_sd
    Avatar
    Community Member
    95 Posts

    Site Title in Email Template Link to this post

    © $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
  • kinglozzer
    Avatar
    Community Member
    139 Posts

    Re: Site Title in Email Template Link to this post

    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

  • merrick_sd
    Avatar
    Community Member
    95 Posts

    Re: Site Title in Email Template Link to this post

    many thanks Loz

    That worked perfectly.

    290 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.