Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » Newsletter Module

Discuss all other Modules here.

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

Page: 1 2 3
Go to End
Author Topic: 2160 Views
  • ocean
    Avatar
    Community Member
    37 Posts

    Re: Newsletter Module Link to this post

    Howdy,

    Trying a number of ways to get unsubscribe to work with current setup of Newsletter (installation as above) and having no luck, just the following response:

    "Sorry, your don't appear to be in any of our mailing lists."

    Anyone familiar with this issue, and even better, how to solve it?

    Its just a plain install of the module, not altered anything yet.

    Best wishes
    ~ Sean

  • ocean
    Avatar
    Community Member
    37 Posts

    Re: Newsletter Module Link to this post

    Fixed!

    Newsletter mod appears to be working perfectly...

    My own fabulously stupid blunder : ) I overlooked setting a mailing list group in "newsletter settings" tab, hopefully this note will help a few avoid that error.

    Now of course subscriptions and unsubscribes are operating as one would expect, and also newsletters are posting to the groups selected, testing very well so far, many thanks Normann and Sam for developing this, now I can get to focusing on developing an audience for my music.

    Warmly
    ~ Sean

  • benni91
    Avatar
    Community Member
    72 Posts

    Re: Newsletter Module Link to this post

    Hi,
    @ first THHHXX !! Your post helped me a lot

    Do you also know how to add an simple Subscription Form ? Just an button and a textfield for the Email ?

    Regards
    Benni

  • Rossel
    Avatar
    Community Member
    18 Posts

    Re: Newsletter Module Link to this post

    @benni91
    This is what i have, its likely a bit more than what your after, but it might help.

    In my Page Controller:

       function SubscribeForm() {
          $email ='';
          $newsletter_group = DataObject::get_one('Group', "ID = 4");
          $member = $this->CurrentMember();
          if($member):
             $email = $member->Email;
          endif;
          if(!$member || !$member->inGroup($newsletter_group)):
             // Create Fields
             $fields = new FieldSet(new EmailField('Email','Email', $email,'100'));
             // Create Action
             $actions = new FieldSet(new FormAction('doSubscribeForm', 'Go'));
             // Create Validators
             $validator = new RequiredFields('Email');
             //Create Form
             $form = new Form($this, 'SubscribeForm', $fields, $actions, $validator );

             return $form;
          endif;
          }

       function doSubscribeForm($data, $form){
          $email = Convert::raw2sql($data['Email']); // prevent sql injection
          $existing_member = DataObject::get_one("Member", "Email = '$email'");
          
          if($member = $this->CurrentMember()):
             // Get member with matching email.
             // If logged in user matches that member add them to newsletter group.
             if($member->ID == $existing_member->ID):
                $newsletter_group = DataObject::get_one('Group', "ID = 4");
                $existing_member->Groups()->add($newsletter_group);
             endif;
             return Director::redirectBack();
          else:
             if($existing_member):
                return Director::redirect(Director::BaseURL() . 'Security/login');
             else:
                return Director::redirect($this->Link("/sign-up/?s=1&e=" . $email));
             endif;
          endif;
          }

    Template:

                <div class="SubscribeForm">
                   <% if SubscribeForm %>
                   $SubscribeForm
                   <% else %>
                   <div> You've subscribed! </div>
                   <% end_if %>
                </div>

  • benni91
    Avatar
    Community Member
    72 Posts

    Re: Newsletter Module Link to this post

    Hi,
    thx for the code - I added the first part to Sidebar.php (Write file? Or is it necessary to add the code somewhere in the newsletter module?)

    and the template code to Newsletter.ss

    <% control getPageByClass(Sidebar) %>
    <div class="SubscribeForm">
    <% if SubscribeForm %>
    $SubscribeForm
    <% else %>
    <div style="padding:8px 20px 11px 20px; height:16px;"> You've subscribed! </div>
    <% end_if %>
    </div>
    <% end_control %>

    but the Problem is, it shows only the text "You've subscribed! " Doesnt matter if logged in or not :/ there's no form.
    What should i do?

  • Rossel
    Avatar
    Community Member
    18 Posts

    Re: Newsletter Module Link to this post

    You'll have to make sure your mailing list group exists and that the group ID is correct:

    $newsletter_group = DataObject::get_one('Group', "ID = 4");

    Maybe try putting the form functions in your Page.php Controller, this is important if you want it to be displayed on more than one page.
    If there is no form found/returned it will display the message, so I'm guessing its not finding it atm.

    Sorry Its not written that well, I'm new to Silverstripe!

  • benni91
    Avatar
    Community Member
    72 Posts

    Re: Newsletter Module Link to this post

    Sry i didn't get it :/

    The group id has to fit to the id of one group i created in the Security section?
    I created a group there called "newsletter subscriber" it's the third group => ID 3? (Doesn't Work)

    If someone wants to subscribe, do he need an account?!
    Ahhh What should i do Help !
    Sry i'm not so good at this

    With
    <% control getPageByClass(Sidebar) %>
    i'm controlling everything on the Sidebar Page. Doesn't matter on which site you are.

  • benni91
    Avatar
    Community Member
    72 Posts

    Re: Newsletter Module Link to this post

    You were right.
    After putting it into the page.php controller it shows me the form.
    but after clicking go i receive an error "Page not found"

    and now? :/

    another problem is: the jquery imageslider stopped working after adding your codes. i think this is a problem of the page_controller
    cause i had this problem on another site too, after adding a contact form code to the page_controller. do someone know how to solve it?

    2160 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.