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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

[solved] SS 3 - email templates, where do they go..


Go to End


3 Posts   2741 Views

Avatar
borriej

Community Member, 267 Posts

10 November 2012 at 9:27am

Edited: 10/11/2012 9:29am

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

Avatar
joelg

Community Member, 134 Posts

10 November 2012 at 11:37am

Edited: 10/11/2012 11:37am

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

Avatar
borriej

Community Member, 267 Posts

12 November 2012 at 1:56am

Hi Joel,

it's solved now.
The problem was a flush

was testing with ?success=1