1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Custom Newsletter Signup Form

Custom Newsletter Signup Form

2 posts, 0 answered
  1. Mike
    Mike avatar
    221 posts
    Registered:
    19 Aug 2008
    12 Mar 2009
    Link to this post
    Evening,

    I need to extend the functionality of the Newsletter Signup Controls... I am looking at ~/Sitefinity/ControlTemplates/Newsletters/SubscriptionFormTemplate.ascx

    If i want to create my own newsletter signup form and then use the functionality of the SubscriptionFormTemplate.ascx form (adding the email and name to the newsletter signup table, etc), how would i go about doing this?

    Thanks,
    Duncan



  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    17 Mar 2009
    Link to this post
    Hi Duncan,

    Please check the forum thread Newsletter Module API Question.
    In short, this is the logic you should be following:
    private static void RegisterNewEmail ( DataManager manager, string email, string fname, string lname, Guid groupId )  
    {  
        // Get the subscriber with the following email. if exist skip the creation of new subscriber.  
        DataManager manager = new DataManager ("Newsletters");  
        ISubscriber newSub = manager.GetSubscriber ( email );  
        if ( newSub == null )  
        {  
            // Create new subscriber object  
            newSub = manager.CreateSubscriber ( email );  
            newSub.FirstName = fname;  
            newSub.LastName = lname;  
            // Save the object.  
            manager.SaveSubscriber ( newSub );  
        }  
      
        // Check if the current subscriber is already subscriped at the following group.  
        IGroupSubscriber gSub = manager.GetGroupSubscriberRelation ( groupId, newSub.SubscriberId );  
        if ( gSub == null )  
        {  
            // Create new object of group subscriber ( Considered as a bridge between the group object  
            //  and the subscriber object.  
            gSub = manager.CreateGroupSubscriberRelation ( groupId, newSub.SubscriberId );  
            // Save the current object  
            manager.SaveGroupSubscribers ( gSub );  
        }  
    }  

    Greetings,
    Georgi
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered