Copied to clipboard

Flag this post as spam?

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


  • Dmitrij Jazel 19 posts 110 karma points
    Jun 07, 2017 @ 18:51
    Dmitrij Jazel
    0

    Move page node via API?

    Hi guys,

    Was wondering if it is possible to move the Node from one node to another?

    I tried asigning another parent to my Umbraco.Core.Models.IPublishedContent.

    But it says IPublishedContent.Parent cannot be asigned -- it is read only.

    Or am I trying to do this in the wrong way? :)

    /Dmitrij

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jun 07, 2017 @ 19:02
    Dirk De Grave
    101

    Hi Dmitrij,

    Can't use IPublishedContent as this is for published content (shown on the front), you need to use the services api to change node's location in the tree.

    See docs here: https://our.umbraco.org/documentation/reference/management/services/contentservice

    Look for Move() method overloads to accomplish what you want

    Cheers, Dirk

  • Dmitrij Jazel 19 posts 110 karma points
    Jun 07, 2017 @ 19:47
    Dmitrij Jazel
    1

    Hi Dirk,

    Thanks for quick reply, and great info. This helped :)

    var service = ApplicationContext.Services.ContentService; // calling service
    var target = service.GetById(1102); //getting target node
    service.Move(target, 1108); // moving page
    
Please Sign in or register to post replies

Write your reply to:

Draft