Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » Newsletter Module: include subscription form

Discuss all other Modules here.

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

Page: 1 2 3
Go to End
Author Topic: 5691 Views
  • Valorinbattle
    Avatar
    Community Member
    95 Posts

    Re: Newsletter Module: include subscription form Link to this post

    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

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: Newsletter Module: include subscription form Link to this post

    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?

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: Newsletter Module: include subscription form Link to this post

    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');

  • Nico
    Avatar
    Community Member
    7 Posts

    Re: Newsletter Module: include subscription form Link to this post

    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

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: Newsletter Module: include subscription form Link to this post

    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.

  • Valorinbattle
    Avatar
    Community Member
    95 Posts

    Re: Newsletter Module: include subscription form Link to this post

    Yurigoul, why will subscribeForm disappear in the near future?

  • Valorinbattle
    Avatar
    Community Member
    95 Posts

    Re: Newsletter Module: include subscription form Link to this post

    Is UserDefinedForms disappearing soon?

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: Newsletter Module: include subscription form Link to this post

    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.

    5691 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.