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


Reply


21 Posts   5816 Views

Avatar
Valorinbattle

Community Member, 95 Posts

4 January 2010 at 5:05pm

Nico, how were you able to get it working? I tried adding this:

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

to my Home.php and the

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

to my Home.ss but I keep getting this error:

[User Error] Uncaught Exception: Object->__call(): the method 'fields' does not exist on 'SubscribeForm_Controller'

Any help would be awesome!
~ Valor

Avatar
yurigoul

Community Member, 202 Posts

13 February 2010 at 1:42am

Same here, running 2.4 Beta (there is a ne release of the Newsletter module or 2.4: RC0.4)

It does work in 2.3.5 so I think userdefinedforms is not ready for 2.4

Did someone get it up and running?

Avatar
yurigoul

Community Member, 202 Posts

16 February 2010 at 1:25am

Edited: 16/02/2010 2:16am

I got it - the code is with translatable enabled and on a newsletter without userdefinedforms. Newsletter apparently doesn't need that module anymore according to one of the maintainers.

EDIT: corrected the following code:

public function ShowForm(){
$LocaleLink = 'Locale = \'' . Translatable::get_current_locale() . '\'';
$get = DataObject::get_one('SubscriptionPage', "URLSegment =" .$LocaleLink );
if (isset($get))
return new SubscriptionPage_Controller($get);

}

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

And don't forget to add the following to the init() of your pages controler in order to get the validation up and runnning (otherwise people can subscribe without a valid email address)

Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); // if you didn't already add this
      
Requirements::javascript(NEWSLETTER_DIR . '/thirdparty/jquery-validate/jquery.validate.min.js');

Avatar
Nico

Community Member, 7 Posts

16 February 2010 at 1:35am

I forgot to mention that you have to create a page named "subscribe" in which you include a subscriptionform.

$get = DataObject::get_one('SubscribeForm', "URLSegment = 'subscribe'");

as you see here, it refers to that urlsegment

Avatar
yurigoul

Community Member, 202 Posts

16 February 2010 at 1:42am

Edited: 16/02/2010 10:01am

The only thing is that SubscribeForm is probably going to disappear in the near future since it is based on UserDefinedForms I believe because it is based on UserDefinedForms. Normann Lou - one of the maintainers of the Newsletter module - urged me to use Subscription Page instead.

Avatar
Valorinbattle

Community Member, 95 Posts

16 February 2010 at 9:25am

Yurigoul, why will subscribeForm disappear in the near future?

Avatar
Valorinbattle

Community Member, 95 Posts

16 February 2010 at 9:53am

Is UserDefinedForms disappearing soon?

Avatar
yurigoul

Community Member, 202 Posts

16 February 2010 at 9:57am

I got the following mail from one of the maintainers:

---------------
We are not using UserForm for Newsletter anymore since 0.3, though there are some code still there and we need to remove them.

Please use the new page type "Subscription Page" which use the similar things as userform but totally detached from user from to avoid:
1.   modules dependency each other.
2.   version conflict each other.

-----------------

SubscribeForm is based on UserDefinedForm and that in turn is defined inside the UserForm module - unless it is also defined somewhere else.