Copied to clipboard

Flag this post as spam?

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

  • Jason Elkin 22 posts 171 karma points
    Nov 14, 2017 @ 15:18
    Jason Elkin

    How does one use TypedContentAtXPath with MultiNodeTreePicker2

    Does anyone know what the below should look like to work with the new MultiNodeTreePicker2?

    Umbraco.TypedContentAtXPath($"//myDoctype[linkedDoc= {Model.Content.Id}]")

    I can see that the value for @linkedDoc is umb://document/1b7f16f0a9034dfeb3f7fb4fdd5b92f4 but I have no idea how to get the equivalent value for my current doc.

  • Alex Skrypnyk 4694 posts 16791 karma points MVP 2x admin
    Nov 14, 2017 @ 15:21
    Alex Skrypnyk

    Hi Jason

    "umb://document/1b7f16f0a9034dfeb3f7fb4fdd5b92f4" is an UDI, read more -

    You don't need to call "Umbraco.TypedContentAtXPath($"//myDoctype[@linkedDoc= {Model.Content.Id}]")", you can use selected cotent item directly in the razor.

    Just get all selected nodes with code like that:

    var typedMultiNodeTreePicker = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("featuredArticles");
  • Jason Elkin 22 posts 171 karma points
    Nov 14, 2017 @ 15:30
    Jason Elkin

    I need all documents of type myDocType where the property value for linkedDoc is my current page - sorry, intial xpath was wrong. Have now fixed.

  • Jason Elkin 22 posts 171 karma points
    Nov 14, 2017 @ 15:47
    Jason Elkin

    Thanks Alex for the link,

    It turns out this is two step process.

    var udi = new GuidUdi("document", this.GetKey());
    var linkedDocs = UmbracoHelper.TypedContentAtXPath($"//myDocType[linkedDoc=\"{udi}\"]");
Please Sign in or register to post replies

Write your reply to: