Copied to clipboard

Flag this post as spam?

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


  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Jun 27, 2014 @ 15:17
    Jesper Ordrup
    0

    Umbraco.TypedContent() - no decendants?

    Hi all,

    In WebApi backend code I'm trying to access the published content using strong typed method.

    var parent = Umbraco.TypedContent(id);

    Then I want to find all decendants - but what works in razor doesnt work here...

    In razor I would do:

     

    var items = parent.Descendants("EventHub").Where(o => o.IsVisible())

    But It seems that Decendants is not avail?

    best

    Jesper

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Jun 27, 2014 @ 15:30
    Jesper Ordrup
    0

    Something about an extension?

     

    best
    Jesper 

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jun 27, 2014 @ 15:43
    Jeavon Leopold
    100

    @using Umbraco.Web; maybe?

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jun 27, 2014 @ 15:44
    Jeavon Leopold
    0

    And add a reference to umbraco.dll

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Jun 27, 2014 @ 15:58
    Jesper Ordrup
    0

    BINGO! Thanks Jeavon. That was not obvious to me :)

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jun 27, 2014 @ 16:00
    Jeavon Leopold
    0

    Awesome, it's because most of those methods are extension methods so you need to the reference.

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Jun 27, 2014 @ 16:12
    Jesper Ordrup
    0

    Thx. Do you know if its mentioned anywhere?
    It's surely an issue for anyone not knowing - and that will push them towards less fantastic code :)

    best
    Jesper 

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Jun 27, 2014 @ 16:25
    Jeavon Leopold
    0

    Unfortunately IPublishedContent itself has not really been documented yet (this is it) and this documentation would also include the extension methods and that they are extension methods. I know it is on the list to be documented soon, but there are never enough hours in the day! :-)

Please Sign in or register to post replies

Write your reply to:

Draft