Copied to clipboard

Flag this post as spam?

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


  • Jeppe Andreasen 10 posts 30 karma points
    Sep 12, 2012 @ 12:51
    Jeppe Andreasen
    0

    Moving a document, and getting an updated niceurl

    I am moving some documents programmatically, and find that although the documents have been moved, their urls are not updated. I have tried republishing everything, unpublish / publish programmatically. The only thing that seems to work is unpublish / republish via. the umbraco backend. Does anybody have a solution to this problem ?

  • Richard Terris 273 posts 715 karma points
    Sep 12, 2012 @ 15:07
    Richard Terris
    0

    You tried calling the Page_Load() Event after publishing?

  • Jeppe Andreasen 10 posts 30 karma points
    Sep 12, 2012 @ 15:25
    Jeppe Andreasen
    0

    Actually this seems to do the trick :

    library.UpdateDocumentCache(document.Id);
    if (document.Published)
    {
        document.UnPublish();
        library.UnPublishSingleNode(document.Id);
        sender.PublishWithResult(document.User);
    }

  • Richard Terris 273 posts 715 karma points
    Sep 12, 2012 @ 15:27
    Richard Terris
    0

    So you're unpublishing the document and then republishing it?

    Will that not have a fair overhead if multiple users are publishing documents?

  • Jeppe Andreasen 10 posts 30 karma points
    Sep 12, 2012 @ 16:18
    Jeppe Andreasen
    0

    Well, yes. And if there is another way to get your niceurl updated programmatically after it has been moved I would love to hear about it.

  • Richard Terris 273 posts 715 karma points
    Sep 12, 2012 @ 17:29
    Richard Terris
    0

    Not sure you need to unpublish. I may be wrong but I think you could move it and then just publish it

    Maybe not but might be worth a try

  • Jeppe Andreasen 10 posts 30 karma points
    Sep 13, 2012 @ 09:19
    Jeppe Andreasen
    0

    That is not enough. It seems to be this line than made it work : 

    library.UnPublishSingleNode(document.Id); ( which I found in the unpublish event handler of the editContent.aspx form using reflector. )

    It is just too bad this issue is not handled inside the move method.

  • Richard Terris 273 posts 715 karma points
    Sep 13, 2012 @ 09:43
    Richard Terris
    0

    Ok that's good to know :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies