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

Forums / Suggestions / Add a "recycle bin"?

Add a "recycle bin"?

5 posts, 0 answered
  1. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    25 Sep 2009
    Link to this post
    One thing I'd really like to see is a "recycle bin" for deleted pages to go into, with access to clear it controlled by roles. Since deleting a page is permanent, we'd like the ability to restore one without refreshing the whole DB from a backup. Also, with a recycle bin, you could see WHO deleted the page, which would be very valuable to us.

    Any plans for this? 
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    25 Sep 2009
    Link to this post
    Hello,

    I have just sent you a code to the other post about tracking deleting of pages that could help you in achieving something like "recycle bin".  From Telerik.ExecutedEventArgs parameter of CmsManager_Executed event you can get the page - its id (e.ItemID). Then you can call CmsManager and get the page. You can save all CMS page properties to a custom table in the database. Then you will have a custom user control that will show the data from this table - the data of deleted pages. In your user control you need to implement simple logic that calls CmsManager.CreatePage(). Thus you will be able to recreate a deleted page and its properties.

    We will consider implementing "recycle bin" of the page and content items for future implementations.

    I hope this helps.

    All the best,
    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. Nadya
    Nadya avatar
    52 posts
    Registered:
    17 Dec 2008
    20 May 2010
    Link to this post
    Hello!

    I am trying to do exactly this but I am always getting null:

    Telerik.Cms.ICmsPage deletedPage = (Telerik.Cms.ICmsPage)manager.GetPage(e.ItemID); // result is null

    Telerik.Cms.ICmsPage deletedPage = (Telerik.Cms.ICmsPage)manager.GetPage(((Telerik.Cms.Data.CmsPage)e.Data).ID); // result is null

    So I am casting the data. But then there is another problem.
    My idea is to duplicate page right before completing the deletion but the following is throwing "Provider cannot be null" exception if there are any controls on the deleted page?! If the page is empty it is working fine.

    Telerik.Cms.ICmsPage deletedPage = (Telerik.Cms.ICmsPage)e.Data;
    Telerik.Cms.ICmsPage newPage = manager.DuplicatePage(deletedPage, "del_" + deletedPage.Name, true);
    newPage.ParentID = new Guid("a2fabae2-1949-4761-a1ef-225e2323538d");
    manager.SavePage(newPage);


    You suggested a custom table in the database and then creating the page again but I cannot imagine how to get page's content in order to recreate exactly the same page.

    Please help,
    thank you,
    Nadya
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    19 Sep 2016
    20 May 2010
    Link to this post
    Hello Nadya,

    If you subscribe for Executing event you can duplicate the page

    void CmsManager_Executing(object sender, Telerik.ExecutingEventArgs e)
      {
          if (e.CommandName == "DeletePage")
          {
              var manager = new Telerik.Cms.CmsManager();
              Telerik.Cms.ICmsPage page  = (Telerik.Cms.ICmsPage)manager.GetPage(((Telerik.Cms.Data.PageBase)(e.CommandArguments)).ID);
     
              Telerik.Cms.ICmsPage newPage = manager.DuplicatePage(page, "REMOVEDPAGEISRESTORED1");
              manager.SavePage(newPage);
     
          }
      }


    You suggested a custom table in the database and then creating the page again but I cannot imagine how to get page's content in order to recreate exactly the same page.

    You should loop through the controls collection and get each control, each CotnentPlaceHolder and each property that has been set. Then add this data to the custom table. This is the only way to get 1: 1 data.

    Best wishes,
    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.
  5. Nadya
    Nadya avatar
    52 posts
    Registered:
    17 Dec 2008
    20 May 2010
    Link to this post
    I see now - of course I should have looked in the continiuos event ...

    And about controls - I got it - thank you very much for the quick and helpful response.

    Have a nice evening!
Register for webinar
5 posts, 0 answered