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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

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

Newsletter subscription field - able to place anywhere?

Go to End

3 Posts   1181 Views

Ryan M.

Community Member, 309 Posts

2 February 2011 at 4:41pm

I'm wondering how to create a fieldset that is simply a box for an email address and a submit button, that connects to the newsletter module, which I can place anywhere in my templates, such as $SubscriptionForm. I want to use the newsletter module, but without using the userdefinedform newsletter page type.


Ryan M.

Community Member, 309 Posts

2 February 2011 at 6:32pm

I thought of a way around this but it seems to be more effort than its worth so I'd still like to hear from anyone if they have any better suggestions.

The idea I have is to just create a dataobject for the signups, store the email address in the object, and set up a tablelistfield in the admin so I can export the addresses to CSV, and import into the newsletter mailing list. This sounds like it'd work in theory, the only bad thing is it's labor intensive and I'd have to repeat the process every time I want to get an updated list of email addresses.


Forum Moderator, 1899 Posts

3 February 2011 at 1:39am

Edited: 03/02/2011 1:40am

how about this...


class NewsletterSignUpWidget extends Widget{
	static $title = "";
	static $cmsTitle = "Newsletter Sign Up";
	static $description = "Newsletter Sign Up - requires page with URL segement 'thanks-for-joining' in the CMS";

class NewsletterSignUpWidget_Controller extends Widget_Controller {
	function NewsletterSignUpForm() {
		$fields = new FieldSet(
			new TextField("FirstName", "Enter your first name: ", ""),
			new EmailField("Email", "Enter your email address: ", "")

		$actions = new FieldSet(
			new FormAction("doform", "Subscribe")

		$required =new RequiredFields(

		return new Form($this, "dosignupform", $fields, $actions, $required);

	function dosignupform($data) {
		$member = new Member();
		$member->FirstName = $data['FirstName'];
		$member->Email = $data['Email'];

		if($group = DataObject::get_one('Group', "Code = 'Newsletter'")){

		// Redirect to a page thanking people for registering, this needs creating int he CMS