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

Forums / General Discussions / Forums module - show locked threads at top of thread list?

Forums module - show locked threads at top of thread list?

8 posts, 0 answered
  1. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    02 May 2011
    Link to this post
    Hi,

    Is it possible for the SingleForum control to float all locked (or "sticky") threads to the top of the thread list?
  2. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    03 May 2011
    Link to this post
    Hi Keith,

    I'm not sure that this is possible using the standard forums module. Have a look at the advanced forums module that is available on Marketplace. It has the feature that allows you to mark threads as "sticky" and always show them at the top of the thread list.

    Best regards,
    Anton
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    03 May 2011
    Link to this post
    Hi ,

    You should create a custom table in the database. In this table you should keep the post/thread ID and whether it is sticky or not. You should implement a button - it could be done on the public part or backend which will mark the post as sticky.Then you have to override CreateSingleForum() of Telerik.Forums.WebControls. Forums and pass a custom datasource  to cntSingleForum.AllThreads.DataSource. In this datasource your sticky posts should be on the top of the posts list.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    03 May 2011
    Link to this post
    Hi Ivan,
    It sounds like that is the route that I am gonna have to go.
    How exactly do I go about overriding CreateSingleForum?  I assume I'm also going to have to override CreatePost as well so that it writes to my custom table as well...
    I thought CreateSingleForum only gets called when the forum is first created though?

    Anton,
    I actually have checked out ct-forums on the marketplace and was impressed with it.  However, they do not have a commercial use license available, which I would need to use it.
  5. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    05 May 2011
    Link to this post
    ...bump?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    09 May 2011
    Link to this post
    Hello Keith,

    Here is a sample that shows how to override the method

    protected override void CreateSingleForum()
            {
                this.cntSingleForum = new SingleForumContainer(this);


                this.tmpSingleForum = ControlUtils.GetTemplate<DefaultSingleForumTemplate>(this.manager.Provider.SingleForumTemplate);
                this.tmpSingleForum.InstantiateIn(this.cntSingleForum);

                this.Controls.Add(this.cntSingleForum);

                this.singleForumDataSource = this.manager.GetForumThreads(this.selectedForumID, true);
                this.cntSingleForum.AllThreads.DataSource = this.singleForumDataSource;
                (this.cntSingleForum.EmptyMessage as WebControl).Visible = this.singleForumDataSource.Count == 0;
                this.cntSingleForum.AllThreads.RowCommand += new GridViewCommandEventHandler(AllThreads_RowCommand);
                this.cntSingleForum.AllThreads.RowDataBound += new GridViewRowEventHandler(AllThreads_RowDataBound);
                this.cntSingleForum.AllThreads.RowCreated += new GridViewRowEventHandler(AllThreads_RowCreated);
                this.cntSingleForum.AllThreads.DataBind();
                // TODO: change - not only admins - also users with special permissions
                if (!Roles.IsUserInRole("Administrators"))
                    this.cntSingleForum.AllThreads.Columns[0].Visible = false;

                this.cntSingleForum.ForumTitle.Text = this.manager.GetForum(this.selectedForumID).Name;
                this.cntSingleForum.BackToForumsButton1.CommandName = "BackToAllForums";
                this.cntSingleForum.BackToForumsButton2.CommandName = "BackToAllForums";
                this.cntSingleForum.BackToForumsButton1.Command += new CommandEventHandler(Button_Command);
                this.cntSingleForum.BackToForumsButton2.Command += new CommandEventHandler(Button_Command);

                this.cntSingleForum.NewThreadButton1.CommandName = "CreateThread";
                this.cntSingleForum.NewThreadButton2.CommandName = "CreateThread";
                this.cntSingleForum.NewThreadButton1.Command += new CommandEventHandler(Button_Command);
                this.cntSingleForum.NewThreadButton2.Command += new CommandEventHandler(Button_Command);
                (this.cntSingleForum.NewThreadButton1 as WebControl).Enabled = this.manager.GetForum(this.selectedForumID).Status != ForumStatus.Locked;
                (this.cntSingleForum.NewThreadButton2 as WebControl).Enabled = this.manager.GetForum(this.selectedForumID).Status != ForumStatus.Locked;
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    (this.cntSingleForum.NewThreadButton2 as WebControl).Visible = this.manager.GetPermission(CrudRights.Create).CheckDemand();
                    (this.cntSingleForum.NewThreadButton1 as WebControl).Visible = this.manager.GetPermission(CrudRights.Create).CheckDemand();
                }
                else
                {
                    IForum selectedForum = this.manager.GetForum(this.selectedForumID);
                    //(this.cntSingleForum.NewThreadButton1 as WebControl).Visible = !selectedForum.DenyAnonymous;
                    //(this.cntSingleForum.NewThreadButton2 as WebControl).Visible = !selectedForum.DenyAnonymous;
                }
            }

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Keith
    Keith avatar
    67 posts
    Registered:
    13 Sep 2010
    09 May 2011
    Link to this post
    Ok so from this code it appears that CreateSingleForum is what gets called every time a forum is displayed on screen? or every time it is created?
    Also am I gonna have to override CreatePost as well?  If not, then where is the best place to write to my custom table when a post is created?
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    12 May 2011
    Link to this post
    Hello Keith,

    Yes the method which Ivan has provided you is executed when a forum is created. You should override the CreatePost method.

    Best wishes,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
8 posts, 0 answered