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 Module: include subscription form


Go to End


19 Posts   7918 Views

Avatar
Nico

Community Member, 7 Posts

2 October 2009 at 11:01pm

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

Community Member, 7 Posts

3 October 2009 at 12:43am

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

Community Member, 7 Posts

3 October 2009 at 12:46am

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

Community Member, 38 Posts

3 October 2009 at 1:08am

Edited: 03/10/2009 1:09am

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

Community Member, 7 Posts

3 October 2009 at 1:16am

using a simple showform throws an error

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

Avatar
b0bro

Community Member, 38 Posts

3 October 2009 at 10:28pm

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

Community Member, 7 Posts

4 October 2009 at 1:45am

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

Avatar
anothersuit

Community Member, 1 Post

27 December 2009 at 5:38am

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