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

Forums / Bugs & Issues / Blog Comments - Can't read comments

Blog Comments - Can't read comments

4 posts, 0 answered
  1. Levi
    Levi avatar
    12 posts
    Registered:
    29 Jun 2008
    28 Jan 2010
    Link to this post
    Hello,

    I'm using Sitefinity 3.5.  When trying to read comments in the comments list, if we are on a page other than the first page of comments and click (read), it takes us back to page 1 and we can't read the comment.   If we are on the first page and click (read) it will actually show us the comment.  This definitly seems like a bug.  Not sure how we can fix this.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Jan 2010
    Link to this post
    Hello Levi,

    It is a bug that persists in the latest release 3.7 SP2 as well. There is way that you can fix the behavior at your end.

    1. You have to upgrade the project to 37 SP2.
    2. You have to replace the default view BlogCommentsView with a custom one.

    There are lot of things that should be overridden

    sample code

    public class CustomBlogCommentsListView : BlogCommentsListView
    {
        public CustomBlogCommentsListView()
        {
        }
     
        public override string LayoutTemplatePath
        {
            get
            {
                return "mytemplate path here";
            }
     
        }
     
        int GridPageIndex
        {
            get
            {
                object obj = this.ViewState["GridIndex"];
                if (obj != null)
                    return (int)obj;
                return 0;
            }
            set
            {
                this.ViewState["GridIndex"] = value;
            }
        }
     
     
       
     
        protected override void InitializeControls(System.Web.UI.Control viewContainer)
        {
            this.CommentsGrid.PageIndex = GridPageIndex;
            base.InitializeControls(viewContainer);
     
            //other logic goes here
     
            ObjectDataSource commentsSource = new ObjectDataSource();
            commentsSource.ID = "CommentsDataSource";
            commentsSource.TypeName = "Telerik.Cms.Engine.ContentManager";
            commentsSource.SelectMethod = "GetComments";
            commentsSource.SortParameterName = "sortExp";
            commentsSource.SelectParameters.Add("filterExp", "");
            commentsSource.SelectCountMethod = "SelectCommentsCount";
            commentsSource.Selecting += commentsSource_Selecting;
            //commentsSource.EnablePaging = true;
     
            if (this.DataItemId != Guid.Empty)
                this.commentsFilterExp = String.Concat("ParentID:", this.DataItemId.ToString(), ";");
     
            if (String.IsNullOrEmpty(this.commentsFilterExp))
                this.commentsFilterExp = String.Concat("GroupID:", this.ParentId.ToString(), ";");
     
            this.Host.Manager.CommentsSortExpression = "DateCreated DESC";
     
            if (canDelete)
            {
                commentsSource.DeleteMethod = "DeleteComment";
                commentsSource.DeleteParameters.Add("id", Guid.Empty.ToString());
                commentsSource.Deleted += this.commentsSource_Deleted;
            }
            commentsSource.ObjectCreating += this.commentsSource_ObjectCreating;
            this.Container.Controls.Add(commentsSource);
     
            if (this.CanSearch)
            {
                this.SearchButton.CommandName = "Search";
                this.SearchButton.Command += this.SearchButton_Command;
            }
     
            this.CommentsGrid.DataSourceID = commentsSource.ID;
            this.CommentsGrid.RowCreated += this.CommentsGrid_RowCreated;
            this.CommentsGrid.RowDataBound += this.CommentsGrid_RowDataBound;
            this.CommentsGrid.DataBound += new EventHandler(CommentsGrid_DataBound);
     
            // other logic goes here
            
        }
     
     
     
        private void CommentsGrid_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                IComment comment = this.Host.Manager.GetComment((Guid)((GridView)sender).DataKeys[e.Row.RowIndex].Value);
     
                foreach (TableCell cell in e.Row.Cells)
                {
                    Control ctrl = cell.FindControl("readComment");
                    string currentUser = UserManager.GetCurrentUserName();
     
                    if (ctrl != null && ctrl is IButtonControl)
                    {
             
                        if (comment.ID == this.readCommentId || comment.IsReadByUser(currentUser))
                        {
                            ctrl.Visible = false;
                        }
                        else
                        {
                            IButtonControl btn = ctrl as IButtonControl;
                            btn.CommandArgument = comment.ID.ToString();
                            btn.Command += btn_Command;
                        }
                    }
     
                    ctrl = cell.FindControl("emStart");
     
                    if (ctrl != null && (comment.ID == this.readCommentId || comment.IsReadByUser(currentUser)))
                        ctrl.Visible = false;
     
                    ctrl = cell.FindControl("emEnd");
                 
                    if (ctrl != null && (comment.ID == this.readCommentId || comment.IsReadByUser(currentUser)))
                        ctrl.Visible = false;
     
                    ctrl = cell.FindControl("hide");
                    if (ctrl != null && ctrl is IButtonControl && comment.Visible)
                    {
                        ctrl.Visible = true;
                        IButtonControl visStatus = ctrl as IButtonControl;
                        visStatus.CommandName = "hide";
                        visStatus.CommandArgument = comment.ID.ToString();
                        visStatus.Command += this.visStatus_Command;
                    }
     
                    ctrl = cell.FindControl("makeVisible");
                    if (ctrl != null && ctrl is IButtonControl && !comment.Visible)
                    {
                        ctrl.Visible = true;
                        IButtonControl visStatus = ctrl as IButtonControl;
                        visStatus.CommandName = "makeVisible";
                        visStatus.CommandArgument = comment.ID.ToString();
                        visStatus.Command += this.visStatus_Command;
                    }
                }
            }
        }
     
        private void btn_Command(object sender, CommandEventArgs e)
        {
            this.Host.Manager.MarkCommentAsRead(this.Host.Manager.GetComment(new Guid((string)e.CommandArgument)), Versioning.Util.GetCurrentUserName());
            this.readCommentId = new Guid((string)e.CommandArgument);
            //base.CommandPanels[0].Refresh();
     
            this.GridPageIndex = CommentsGrid.PageIndex;
            this.RecreateChildControls();
            this.Page.MaintainScrollPositionOnPostBack = true;
        }
     
     
         
    }


    Sincerely yours,
    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. Levi
    Levi avatar
    12 posts
    Registered:
    29 Jun 2008
    29 Jan 2010
    Link to this post
    Thanks Ivan.  Bummer it's a bug that requires an upgrade, but that's how these things go....
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    29 Jan 2010
    Link to this post
    Hello Levi,

    The upgrade will not fix the problem at all. You will have to do step 2 as well.

    Best wishes,
    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.
Register for webinar
4 posts, 0 answered