Copied to clipboard

Flag this post as spam?

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


  • Michael 24 posts 137 karma points
    Jun 12, 2014 @ 21:55
    Michael
    0

    umbraco.library:GetXmlAll() razor version

    Hi guys

    I am currently working on converting all my old XSLT files to Razor. My scenario is the following:

    I need to fetch all nodes of a specific doctype. Not from currentpage. In XSLT I would do it like this:

    umbraco.library:GetXmlAll()//doctypeAliasHere

    My question is, how do I do it in razor? :)

     

    /Michael

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jun 14, 2014 @ 08:53
    Jeavon Leopold
    1

    Hi Michael,

    It would be @CurrentPage.AncestorOrSelf(1).Descendants("docTypeAlaias")

    This would return all of the nodes from the root node of the site being rendered, if you had multiple root nodes (sites) and wanted all nodes from all sites, then there would be a different solution.

    Jeavon

  • Michael 24 posts 137 karma points
    Jun 18, 2014 @ 22:31
    Michael
    0

    Hi Jeavon

    My umbraco structure looks like this:

    Homepage
    - Subpages
    Language version
    - Hompage
    -- Subpages
    Language version 2
    - Homepage
    -- Subpages
     

    I need something to fetch all the language version doctypes.

     

    Michael

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jun 20, 2014 @ 10:50
    Jeavon Leopold
    0

    Hi Michael,

    So they are all siblings under the root node?

    Jeavon

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jun 20, 2014 @ 12:48
    Jeavon Leopold
    101

    Umbraco.TypedContentAtRoot() will return you a collection of all the level 1 nodes, if you want only certain Document Types in this collection, then Umbraco.TypedContentAtRoot().OfTypes("myFirstDocType", "mySecondDocType");

  • Michael 24 posts 137 karma points
    Aug 27, 2014 @ 07:52
    Michael
    0

    Hi Jeavon

    Sorry for not getting back to you. Been a busy summer :)

    I will check your solution out this weekend when i get some playtime :)

    Thanks

    /Michael

  • Michael 24 posts 137 karma points
    Sep 08, 2014 @ 13:53
    Michael
    0

    Hi again Jeavon

    That did the trick. Thank you very much :)

     

    /Michael

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Sep 08, 2014 @ 13:56
    Jeavon Leopold
    0

    Great!

Please Sign in or register to post replies

Write your reply to:

Draft