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.

All other Modules

Discuss all other Modules here.

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

Newsletter Module: include subscription form


Go to End
Reply

21 Posts   5793 Views

Avatar
Nico

2 October 2009 at 11:01pm Community Member, 7 Posts

Hello all,

I have created a subscription form to register on the newsletter lists. Is there a way to publish this form on other pages, for example in the sidebar?

greets,
Nico

Avatar
Nico

3 October 2009 at 12:43am Community Member, 7 Posts

i managed to show the form on other pages by putting this in the pagecontroller

function ShowForm(){
$get = DataObject::get_one('UserDefinedForm', "URLSegment = 'subscribe'");
return new UserDefinedForm_Controller($get);
}

and this in page.ss

<% control ShowForm %>
$Form
<% end_control %>

However the available newsletter lists checkboxes are not included, does anyone have an idea what could be causing this?

Avatar
Nico

3 October 2009 at 12:46am Community Member, 7 Posts

seems i was a bit hasty, this does the trick

function ShowForm(){
$get = DataObject::get_one('SubscribeForm', "URLSegment = 'subscribe'");
return new SubscribeForm_Controller($get);
}

Avatar
b0bro

3 October 2009 at 1:08am (Last edited: 3 October 2009 1:09am), Community Member, 38 Posts

correct me if i'm wrong, but wouldnt a simple $ShowForm in the .ss template be sufficient? I cant see the need for the control?

Avatar
Nico

3 October 2009 at 1:16am Community Member, 7 Posts

using a simple showform throws an error

"Uncaught Exception: Object->__call(): the method 'fortemplate' does not exist on 'SubscribeForm_Controller'"

Avatar
b0bro

3 October 2009 at 10:28pm Community Member, 38 Posts

Interesting, i should have tested it before opening my big mouth!

What about $Showform.Form ??

Ive done this on a site before, ill have to dig up the code when i get back to work. I know there isnt much point if your method works, but im just interested thats all!

Avatar
Nico

4 October 2009 at 1:45am Community Member, 7 Posts

nice, that worked too, much cleaner, thanks for the tip :)

Avatar
anothersuit

27 December 2009 at 5:38am Community Member, 1 Post

I would like to include the newsletter subscription form to my Homepage. I have tried the previously mentioned ways but cant seem to get it to show. I noticed this in my Page.ss file - $Form -. I copied and pasted this to my HomePage.ss file and nothing.

I am not sure of the solution. I am new to Silverstripe. If anyone has any ideas that would be great thanks.

Go to Top