Copied to clipboard

Flag this post as spam?

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


  • Sébastien Richer 194 posts 430 karma points
    Feb 18, 2013 @ 20:43
    Sébastien Richer
    0

    Umbraco 6 looking for someNode.DescendantsOrSelf("nodeType")

    Hello,

    Starting in Umbraco 6 now, but I'm having trouble finding the methods I'm looking for (maybe I'm not looking for the right ones).

    Basically I'm looking for someNode.DescendantsOrSelf("nodeType"), which I used to use a lot in older projects. How do we accomplish this now in Umbraco 6?

     

    Thanks!

     

     

  • Andreas Iseli 150 posts 427 karma points
    Feb 18, 2013 @ 21:44
    Andreas Iseli
    0

    You must reference the PublishedContentExtensions from the Umbraco.Web namespace. There you will find those methods.

    Regards

  • Sébastien Richer 194 posts 430 karma points
    Feb 18, 2013 @ 21:53
    Sébastien Richer
    0

    Ohh I see! So this here would be right?

    @using Umbraco.Web.Models
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    @{
        var descendants = ((DynamicPublishedContent)CurrentPage).Descendants("someType");
    }

    Is there a better (without casting) way of doing this?

    Thanks!

  • Andreas Iseli 150 posts 427 karma points
    Feb 18, 2013 @ 22:01
    Andreas Iseli
    100

    Just add @using Umbraco.Web.PublishedContentExtensions and use the extension methods directly over Model.Content

    Regards


  • Sébastien Richer 194 posts 430 karma points
    Feb 18, 2013 @ 22:02
    Sébastien Richer
    0

    Perfect! Thanks for the help!

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Mar 18, 2013 @ 21:57
    David Brendel
    0

    Have tried to add the 

    @using Umbraco.Web.PublishedContentExtensions

    but he tolds me that this is a type and not a namespace.

    How can i use the Extensions?

    Sitting on Umbraco 6.0.0.

    Thanks in advance!

  • Sébastien Richer 194 posts 430 karma points
    Mar 18, 2013 @ 22:07
    Sébastien Richer
    0

    David, maybe you are missing a reference in your Visual Studio project?

Please Sign in or register to post replies

Write your reply to:

Draft