More in this section

Forums / Developing with Sitefinity / Check content item is editing

Check content item is editing

4 posts, 0 answered
  1. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    21 Jun 2010
    Link to this post

    Hi!

    Can you describe main idea for checking content item or page is now editing? If someone edits content item I need to show this in list of content. How can I do this?

    Thank you.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Jun 2010
    Link to this post
    Hi Paul,

    The ideas is that if someone edits an object you should not interrupt it and clear its changes. So, we lock the object until a given user save it and we allow only administrators to unlock an object before that( programmatically you can unlock items event if you are not an administrator)
    The GenericContent module shows when someone else is editing an item inside the module. You should see Locked by "your user name" in the status column. The same applies for pages.

    If you are using GenericConten control and you are editing a shared content item the object does not get locked and this is not indicated in the backend section. We lock only the page. There is a workaround for this case, but it requires overriding GenericContent control to apply the quick fix.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    21 Jun 2010
    Link to this post

    Hi Ivan!

    Thank you for the reply. Can you describe a workaround for the Generic_Content case? What and how I should override? 

    Thank you.

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Jun 2010
    Link to this post
    Hello Paul,

    1. You need to create a custom class that inherits from GenericContent

    2. Then create a ControlDesigner for the custom GenericContent control and check the CommandName when "Edit Shared content" button is clicked.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Cms.Engine.WebControls.Design;
    using Telerik.Cms.Engine;
     
    /// <summary>
    /// Summary description for GenericContentDesignerTest
    /// </summary>
    public class GenericContentDesignerTest : GenericContentDesigner
    {
        public GenericContentDesignerTest()
        {
            //
            // TODO: Add constructor logic here
            //
        }
     
        protected override void InitializeControls(System.Web.UI.Control viewContainer)
        {
            base.InitializeControls(viewContainer);
            this.Container.EditSharedContent.Command += new System.Web.UI.WebControls.CommandEventHandler(EditSharedContent_Command);
        }
     
        void EditSharedContent_Command(object sender, System.Web.UI.WebControls.CommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {
               IContent cntItem  =  Manager.GetContent(this.DesignedControl.ContentID);
               if (cntItem != null)
               {
                   // getting the staged content will lock it.
                  StagedContent staged =  (StagedContent)Manager.GetStagedContent(cntItem.ID);
               }
            }
        }
     
        
    }


    3. Map the custom GenericContent control the the newly created designer.

    [ControlDesignerAttribute("GenericContentDesignerTest, App_Code")]


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about 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
4 posts, 0 answered