Copied to clipboard

Flag this post as spam?

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


  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    May 07, 2013 @ 13:33
    Peter Gregory
    0

    Resync the tree after a custom event moves a node

    I have a custom Event that moves a node before its published but I the tree closes and does not reopen to that node after the move.

    I have tried putting the following in after the event has occured

    BasePage.Current.ClientTools.SyncTree(sender.Path, true);

    But it does not seem to have the desired effect.  Im sure i am just doing it wrong but I am sure that it worked in the past. Any pointers or corrections on how I should approach it would be appreciated. 

  • Mads Krohn 211 posts 504 karma points c-trib
    May 07, 2013 @ 14:04
    Mads Krohn
    0

    If you are moving nodes, perhaps try

    BasePage.Current.ClientTools.MoveNode(string currentNodeId, string newParentPath);

    I've used that before with success.

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    May 07, 2013 @ 14:17
    Peter Gregory
    0

    Nope doesnt seem to work.

    at what point should I be calling that?  I am doing it at the end of the beforePublish event

    private void Document_BeforePublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e){
    .... lots of event code.....
    sender.Move(someDoc.Id);
    library.RefreshContent();
    BasePage.Current.ClientTools.MoveNode(sender.Id.ToString(), sender.Parent.Path);

    So what am I doing wrong?

  • Mads Krohn 211 posts 504 karma points c-trib
    May 07, 2013 @ 15:05
    Mads Krohn
    0

    Hmm, I think you need to do something like

    BasePage.Current.ClientTools.MoveNode(sender.Id.ToString(), new Document(sender.Id).Path);

    as I don't think the Path property of the Document object will be updated when calling .Move. I think you simply need to make the document again to get the new path.

  • John French 32 posts 83 karma points
    Oct 24, 2013 @ 07:10
    John French
    0

    Hi,

     

    Did you resolve this? I'm also having problems refreshing the tree and opening at the correct node after moving a document.

     

    thanks

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Oct 24, 2013 @ 07:17
    Peter Gregory
    0

    Hi James

    This is how I resolved it. where p is the newly moved and published document.

    var ct = new Umbraco.Web.UI.Pages.ClientTools(Page);
    ct.MoveNode(p.Id.ToString(), p.Path);
    

    Hope this helps

  • John French 32 posts 83 karma points
    Oct 24, 2013 @ 12:52
    John French
    0

    thanks..i'm actually using version 4.11. i'll keep trying..cheers

Please Sign in or register to post replies

Write your reply to:

Draft