Jump to:

23459 Posts in 18906 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » [solved] SS 3 - email templates, where do they go..

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 928 Views
  • borriej
    Avatar
    Community Member
    267 Posts

    [solved] SS 3 - email templates, where do they go.. Link to this post

    Hello,

    Im using SS 3.02, with a contactform class, uses a template to send the form data.
    Where do i store the email template?

    this is all wrong:
    /themes/Mytheme/templates/Email/contactEmail.ss
    /themes/Mytheme/templates/Includes/contactEmail.ss
    /themes/Mytheme/templates/Layout/contactEmail.ss
    /mysite/templates/Email/contactEmail.ss
    /mysite/templates/contactEmail.ss

    So what is the correct place?

    <?php
    class ContactPage extends Page{
       static $db = array(
          'Mailto' => 'Varchar(100)',
          'SubmitText' => 'HTMLText',
       );
       function getCMSFields() {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab("Root.OnSubmission", new TextField('Mailto', 'Email submissions to'));   
          $fields->addFieldToTab("Root.OnSubmission", new HTMLEditorField('SubmitText', 'Text on Submission'));   
          return $fields;
       }
    }

    class ContactPage_Controller extends Page_Controller{
       static $allowed_actions = array(
          'ContactForm'
       );
       function ContactForm(){
          $fields = new FieldList(
    new TextField('Budget', 'Budget'),
    new TextField('Naam', 'Naam'),
    new TextField('Email', 'Email'),
    new TextareaField('Bericht', 'Bericht')
          );
        $actions = new FieldList(
           new FormAction('SendContactForm', 'Verstuur')
        );
          $validator = new RequiredFields('Naam', 'Email', 'Bericht');
        return new Form($this, 'ContactForm', $fields, $actions, $validator);
       }
       
       function SendContactForm($data, $form){
          $From = $data['Email'];
          $To = $this->Mailto;
          $Subject = "Bericht via contactformulier";    
          $email = new Email($From, $To, $Subject);
          $email->setTemplate('ContactEmail');
          $email->populateTemplate($data);
          $email->send();
       
          Director::redirect(Director::baseURL(). $this->URLSegment . "/?success=1");
       }

       //The function to test whether to display the Submit Text or not
       public function Success(){
          return isset($_REQUEST['success']) && $_REQUEST['success'] == "1";
       }
    }

    The error is:

    [user warning] None of these templates can be found in theme 'Mytheme' ContactEmail.ss

    Line 633 in SSViewer.php

  • joelg
    Avatar
    Community Member
    129 Posts

    Re: [solved] SS 3 - email templates, where do they go.. Link to this post

    Hi,

    You should name the file ContactEmail.ss and place the file in your templates folder, either in mysite or your theme.

    You seem to have named the file contactEmail.ss...

    Joel

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: [solved] SS 3 - email templates, where do they go.. Link to this post

    Hi Joel,

    it's solved now.
    The problem was a flush

    was testing with ?success=1

    928 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.