17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2887 Views |
-
Custom email template

29 October 2007 at 12:47pm
Hello
I'm looking for solution how to add custom email template on user defined form ( contact form ) submits .
When form is emailed it looks like it using Page.ss which is bad for me:)
How to add customized template for emailed submitted user form? -
Re: Custom email template

29 October 2007 at 3:07pm
There's 2 solutions:
1. You make a contact form in code, rather than use the 'contact form' in the CMS - this way you get full control over making it. See the 3rd tutorial for more information on this.
2. Subclass UserDefinedForm, and hack the code so it chooses a different template. (Not the best solution).
Cheers,
Sean -
Re: Custom email template

30 October 2007 at 10:30pm
can u help to place dropdown controls from middle of the page ... help me please
-
Re: Custom email template

30 October 2007 at 11:10pm
OK, I used http://doc.silverstripe.com/doku.php?id=email_template end works almost perfect but there are three problems:
1. How to add translated validation messages? Page is in Polish and have to translate validation messages
2. How to add proper encoding to email? I have bad characters when email is submitted
3. How to add confirmation message that the email has been sendfunction doContactForm ( $data, $form )
{
$submission = new ContactFormSubmission();
$form->saveInto($submission);
$submission->write();
// send email
$email = new Email_Template();
$email->ss_template = "ContactFormEmail";
$email->populateTemplate($submission);
$email->subject = $submission->val( "Subject" );
$email->from = $submission->val("Email");
$email->to = "info@somedomain.pl";
$email->send();
// ---
Director::redirectBack();
}Template:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head>
</head>
<body><p class="body">
<p>Wiadomość wysłana przez $Name z formularza kontaktowego:</p>
$Content
</p></body>
</html> -
Re: Custom email template

30 October 2007 at 11:48pm
Ok now I need only two answers:)
3. How to add confirmation message that the email has been send?
I had to add SubmittedContactArticlePage.ss and works perfect:)
-
Re: Custom email template

31 October 2007 at 9:43am
Just before Director::redirectBack() you can call:
$form->sessionMessage('Thanks, you've been signed up', 'good');
Cheers,
Sean -
Re: Custom email template

1 November 2007 at 12:09am
Great
Are there some messages like 'good' for replacing validation messages?
| 2887 Views | ||
|
Page:
1
|
Go to Top |


