Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • John 27 posts 49 karma points
    May 11, 2010 @ 12:50
    John
    0

    Deleting Child Nodes

    Hi,

    Does anyone know of a way of deleting all child nodes from a node without going through each one individually.

    The node in questions has 100+ items within it and is one of many.

    I am guessing this issue isn't unique to me and someone may know of a package that can do this.

    Thanks

    John

    PS

    Sorry for my first post to be a cry for help.

  • Stefan Kip 1614 posts 4131 karma points c-trib
    May 11, 2010 @ 14:54
    Stefan Kip
    0

    Hmm, well, I'm going to develop a 'Bulk Actions' package for Umbraco next week or so, but that doesn't help you at this point ;-)

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    May 11, 2010 @ 15:23
    Sebastiaan Janssen
    1

    You can delete the parent node, that will delete all the child nodes.. But you'd have to recreate the parent. Still, it would save you some time.. ;-)

  • Justin Moore 41 posts 100 karma points
    May 13, 2010 @ 04:14
    Justin Moore
    3

    You can do it in code something like this:

    Document parentNode = new Document(1350);//use id of parent node 
    foreach (Document child in parentNode.Children)
    {
        child.delete();
            umbraco.library.UpdateDocumentCache(child.Id);    
    }
    umbraco.library.RefreshContent();

    You'd need to hang that off a button somewhere, guess easiest would be make a user control and stick it in a doc restricted to admins, else you could make something in the umbraco admin if you're into that.

    You need to ref umbraco cms.dll too

    using umbraco.cms.businesslogic.web;

     

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    May 13, 2010 @ 09:05
    Hendy Racher
    1

    just a thought, how about adding the "delete all children" option (with a confirmation dialog) to the right click context menu on the content tree ?

    http://umbraco.tv/documentation/videos/for-developers/events/add-items-to-the-context-menu

  • John 27 posts 49 karma points
    May 27, 2010 @ 15:48
    John
    0

    Hi Thanks for the reply's I created a user control to delete the node, when i find time i will create a package i think which adds this.

     

    Thanks

    John

  • Eduardo Sobrinho 18 posts 38 karma points
    Feb 18, 2015 @ 20:38
    Eduardo Sobrinho
    0

    I used ContentService (https://our.umbraco.org/documentation/Reference/Management-v6/Services/ContentService).

    See the snipet below (vb.net)

    Private Sub MyDeleteSub(id as integer)
    Dim cs = umbraco.Core.ApplicationContext.Current.Services.ContentService
      Dim page = cs.GetById(id)
      cs.Delete(page)
    End Sub

    (Sorry my English. I'm Brazilian)

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Feb 19, 2015 @ 08:51
    Richard Soeteman
    0

    Also might be worth to check our free version of bulkmanager that does this. http://soetemansoftware.nl/bulkmanager

    Cheers,

    Richard

  • Eduardo Sobrinho 18 posts 38 karma points
    Feb 20, 2015 @ 00:18
    Eduardo Sobrinho
    0

    Thanks,

    I'll try it tomorrow.

    Eduardo

Please Sign in or register to post replies

Write your reply to:

Draft