Copied to clipboard

Flag this post as spam?

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


  • Stephan Lonntorp 195 posts 212 karma points
    Jan 05, 2011 @ 08:33
    Stephan Lonntorp
    0

    Moving CMSNode via API, causes strange data in the Node API

    OK, so here's the scenario:

    A user clicks a button, and a page (1307) is then moved to another part of the site.

    The original location (path): -1,1113,1202,1288,1291,1307

    The new location (path): -1,1113,1201,1295,1298,1307

    I accomplish it this way (code removed for brevity):

    myDocument.Move(1298);
    myDocument.Save();
    myDocument.Publish(new User(0));
    umbraco.library.UpdateDocumentCache(myDocument.Id);

    Now, this works fine, almost. The document is moved in the tree. The path is updated to reflect its new position in the hierarchy. But. The Node isn't moved in the XML, not even after a complete republish, so getting the data via the Node API (.Parent for instance), gives med the old parent (1291), when it should be 1298.

    What do I need to do here? Flush the entire cache? Update the parents document cache?

    Should it be possible for a Node to have a path that isn't reflected by its actual position in the node structure?

    Help!

    //Stephan

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 05, 2011 @ 09:13
    Dirk De Grave
    0

    Can you repro this on other nodes as well? Had a look at the source code for a Move() but wasn't really able to pinpoint where it may go wrong...

    If you can repro this on other nodes as well, I'd log this as a bug on Codeplex, to get the core team's attention.

    Don't see anything wrong with the code you provided

    Cheers,

    /Dirk

  • Stephan Lonntorp 195 posts 212 karma points
    Jan 05, 2011 @ 09:25
    Stephan Lonntorp
    0

    It seems as if doing

     

    umbraco.library.UpdateDocumentCache(myDocument.ParentId);
    umbraco.library.UpdateDocumentCache(myDocument.Id);

    solves it. Does nothing at all.

    I'll create an issue on CodePlex.

Please Sign in or register to post replies

Write your reply to:

Draft