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

Forums / Developing with Sitefinity / Programmatic Recycle vs. Delete SF 7.1

Programmatic Recycle vs. Delete SF 7.1

2 posts, 0 answered
  1. Scott Rozman
    Scott Rozman avatar
    93 posts
    Registered:
    10 Oct 2012
    22 Jul 2014
    Link to this post

    Today, I looked into how to recycle content items from the Module Builder instead of delete them.

    It would have been nice to see this in the generated API documentation for my content types, but I found this other documentation which got me part of the way.

    http://www.sitefinity.com/documentation/documentationarticles/sending-items-to-the-recycle-bin

    The technique is almost the same as the news version above:

    dynamicModuleManager.RecycleBin.MoveToRecycleBin(master);

    So instead of just getting the data item and moving it to the recycle bin, you need to get the data item, get its master and then move the master.

    Since the documentation is still a bit sparse, I thought I'd post this.

    DynamicContent resourceItem = dynamicModuleManager.GetDataItem(resourceType, resourceID);
    var master = dynamicModuleManager.Lifecycle.Edit(resourceItem) as DynamicContent;
     
    if (master != null)
    {
        dynamicModuleManager.RecycleBin.MoveToRecycleBin(master);
    }

  2. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    21 Nov 2016
    25 Jul 2014
    Link to this post
    Hi,

    Thank you for sharing the code with the community. I will forward it to our documentation team.

    Regards,
    Stefani Tacheva
    Telerik
     
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
2 posts, 0 answered