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

Forums / Developing with Sitefinity / forum subscribe option.

forum subscribe option.

8 posts, 0 answered
  1. Muhammad Saqib
    Muhammad Saqib avatar
    95 posts
    Registered:
    09 Sep 2009
    21 Dec 2009
    Link to this post
    i want to add a function in forum just like "Subscribe to this thread:" and "subscribe to this forum" .
    Can someone please guide me on this..

    Thanks.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Dec 2009
    Link to this post
    Hi Muhammad Saqib,

    First you need to create a subscribe button and unsibscribe button, so that the user can unsubscribe from the post. You need to create a  new database table where you have to store the userID, ForumID and PostID, userEmail The userID table should store the subscribed user ID and make relation to the user email address. The email address have to be persisted in the same table. Once a new post is posted to the thread you will get all users from the newly created database and send an email to them. You can use Posts.Count ICollection if IForum object to determine whether a new post is created. Only in this case you will notify your subscribers. To notify the subscriber you can use DataManager class( from Newsletters module) or standard ASP.NET MailMessage class.

    The unsubscribe link will just delete the user from your table. You can even add unsubscribe link to the email message body so that once a subcriber receive your email he/she could click on the link and then get redirected to a unscubscription page of your website.


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Muhammad Saqib
    Muhammad Saqib avatar
    95 posts
    Registered:
    09 Sep 2009
    22 Dec 2009
    Link to this post
    Thanks,
    well.. that's almost the same what i am looking for..
    but how to get events of

    1) new thread  ( new thread in specific forum)
    2) reply to thread
    3) new post in some specific forum.

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    22 Dec 2009
    Link to this post
    Hello Muhammad Saqib,

    I suggest that you should go through the following articles Forums API Overview

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Muhammad Saqib
    Muhammad Saqib avatar
    95 posts
    Registered:
    09 Sep 2009
    01 Jan 2010
    Link to this post
    well i got this article .. but in  this article its assuming "threadID" in the Querystring, but i found no "threadID" in the querystring......
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    03 Jan 2010
    Link to this post
    Hi Muhammad Saqib,

    You have to set SingleThreadPage property of Forums control or SingleForumPage property of the same control. Then you can read the data from the QuerySting and copy/paste the blog post logic.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Chris Williams
    Chris Williams avatar
    14 posts
    Registered:
    25 Oct 2004
    06 Feb 2010
    Link to this post
    Hi Ivan, I saw your blog post here about implementing the subscription service for forums, which is just what I want to do.

    I'm hung up on the basics though.  You say that you "create a code behind of this template", but what is the process for that?  Did you put these classes in App_Code, or do they go into the folder where the Forum Control Template lives?  Do you have to change the reference then on the ASCX file to reference the new partial class?

    thanks,

    Chris
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    07 Feb 2010
    Link to this post
    Hello Chris Williams,

    In ASP.NET you can write the server code in a separate file - cs - which is code behind or you can write it in the control template ascx.

    sample

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="EditPost.ascx.cs" Inherits="Sitefinity_ControlTemplates_Forums_EditPost" %>

    public partial class Sitefinity_ControlTemplates_Forums_EditPost : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
            this.saveButton.Click += new EventHandler(saveButton_Click);
        }
     
        void saveButton_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["mode"]) && !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["thread"]))
            {
                // get the thread ID.
                Guid ThreadID = new Guid(HttpContext.Current.Request.QueryString["thread"].ToString());
                ForumSubscriptionDataContext dataContext = new ForumSubscriptionDataContext();
                string uri = HttpContext.Current.Request.Url.ToString();
                // get our subscriber
                var query = from sub in dataContext.ForumSubscribers
                            where sub.ThreadID == ThreadID
                            select sub.UserEmail;
                // send email to our subscriber that there is a new post
                foreach (var email in query)
                {
                    MailMessage message = new MailMessage("yourhost@here.com", email);
                    message.IsBodyHtml = true;
                    message.Body = "<b>ThreadConversation</b>:" + tbQuote.Content + "<b>LastReply is:</b>" + editor.Content + "<br />" + "<i>Click the link below to reply</i>" + "<p>" + uri;
                    message.From = new MailAddress("yourhost@here.com");
                    message.Sender = new MailAddress("yourhost@here.com");
                    SmtpClient client = new SmtpClient();
                    client.Send(message);
                }
                dataContext.Dispose();
            }
        }
     
        
        private Guid selectedParentID;
    }


    Regards,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Register for webinar
8 posts, 0 answered