10378 Posts in 2194 Topics by 1710 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 714 Views |
-
Newsletter subscription field - able to place anywhere?

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.
Ideas??
-
Re: Newsletter subscription field - able to place anywhere?

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.
-
Re: Newsletter subscription field - able to place anywhere?

3 February 2011 at 1:39am Last edited: 3 February 2011 1:40am
how about this...
mysite\widgets\NewsletterSignUpWidget.php
<?php
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(
"FirstName",
"Email"
);return new Form($this, "dosignupform", $fields, $actions, $required);
}function dosignupform($data) {
$member = new Member();
$member->FirstName = $data['FirstName'];
$member->Email = $data['Email'];
$member->write();if($group = DataObject::get_one('Group', "Code = 'Newsletter'")){
$member->Groups()->add($group);
}// Redirect to a page thanking people for registering, this needs creating int he CMS
Director::redirect('/thanks-for-joining');
}
}mysite\widgets\NewsletterSignUpWidget.ss
$NewsletterSignUpForm
| 714 Views | ||
|
Page:
1
|
Go to Top |


