Copied to clipboard

Flag this post as spam?

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


  • Tobias M. Madsen 12 posts 102 karma points
    Aug 30, 2019 @ 08:35
    Tobias M. Madsen
    0

    Relation after creating node

    I'm kind of new to the relationservice and how it works, but awesome feature so far. I'm still trying to figure out one simple thing, is it only possible to "create" a relation when copying a node?

    Context: Site with two languages i'm connecting so when you switch from one to another, it switches to the respective node/page in the other language.

    I'm trying to connect / set relation on two nodes, after I've created them, but don't think it's possible?

  • Paul Seal 524 posts 2889 karma points MVP 7x c-trib
    Aug 30, 2019 @ 09:03
    Paul Seal
    1

    Hi Tobias

    You can create relations programatically yourself.

    See the documentation here https://our.umbraco.com/documentation/reference/management/services/relationservice/

    There is an example of creating a relation in that, regarding favourites.

    var rs = ApplicationContext.Current.Services.RelationService;
    // create relation
    var relType = rs.GetRelationTypeByAlias("memberFavorites");
    var r = new Relation(memberId, contentId, relType);
    rs.Save(r);
    

    Cheers

    Paul

  • Tobias M. Madsen 12 posts 102 karma points
    Aug 30, 2019 @ 12:37
    Tobias M. Madsen
    0

    Was more looking for a way to do it from the backoffice, like manually setting a relation to a selected node.

    But appreciate the answer :)

  • Kevin Jump 2342 posts 14889 karma points MVP 8x c-trib
    Aug 30, 2019 @ 13:00
    Kevin Jump
    100

    Hi Tobias,

    on Umbraco 7 - the "linked pages" package lets you control the relations between pages/

    https://our.umbraco.com/packages/backoffice-extensions/linked-pages/

    haven't release the v8 one yet, but its in the works.

  • Tobias M. Madsen 12 posts 102 karma points
    Sep 01, 2019 @ 18:31
    Tobias M. Madsen
    0

    Nice one! I'll definitely give it a look :)

Please Sign in or register to post replies

Write your reply to:

Draft