10848 Posts in 2516 Topics by 1792 members
|Go to End|
19 October 2010 at 1:14am
I'm running SS 2.4.2 and have installed the newsletter module.
I have setup a newsletter subscription page type just containing an email field so that users can register easily.
What I'd like to do though is make this form appear as a widget so I can insert it in the sidebar of my home page (which has already been setup to display widgets).
How do I do this?
I tried using the page content and single page widgets in the hope that they would simply display the form content from my subscription page within the widget, however it seems that these widgets assume a normal sitetree page type and will only output the 'content' field rather than the form.
Are there any other ways round this? Am I missing an obvious solution?
Any help will be much appreciated.
19 October 2010 at 9:20pm
Hi, How's 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
$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);
$member = new Member();
$member->FirstName = $data['FirstName'];
$member->Email = $data['Email'];
// Write it to the database. This needs to happen before we add it to a group
// Add the member to group. (Check if it exists first)
if($group = DataObject::get_one('Group', "Code = 'Newsletter'"))
// Redirect to a page thanking people for registering, this needs creating int he CMS
20 October 2010 at 3:10am
That's great, thanks! Works a treat.
I'm still quite new to SS, so am still getting my head around the way things work, but this has been a big help in more ways than one.
|Go to Top|