Copied to clipboard

Flag this post as spam?

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


  • Paul Aikman 43 posts 97 karma points
    Feb 17, 2014 @ 14:56
    Paul Aikman
    0

    uQuery.GetNodesByType equivalent in UmbracoHelper?

    Hi,

    Just getting stuck into the v6 API and I'm wondering if there is an UmbracoHelper equivalent of uQuery.GetNodesByType("myDocTypeName")? 

    If not - are there performance penalties for using uQuery instead of UmbracoHelper, or is it just preferable to use UmbracoHelper to help future-proof my app?

    Cheers,

    Paul

  • Dan Lister 416 posts 1974 karma points c-trib
    Feb 17, 2014 @ 15:48
    Dan Lister
    0

    If you can implement it with UmbracoHelper than I'd use that. It looks like uQuery has become a little obsolete after reading about it on uQuery's documentation page. You could use the following method from Umbraco Helper to find all content of a certain type. Check out the answer to this post for more info.

    @Umbraco.TypedContentAtRoot().DescendantsOrSelf("docTypeAlias");
  • Paul Aikman 43 posts 97 karma points
    Feb 17, 2014 @ 18:29
    Paul Aikman
    0

    Thanks Dan, nailed it.

    If you're hitting this page and are looking for the DescendantsOrSelf method on TypeContentAtRoot(), you'll need this extension (until 6.2 rolls in):

    public static IEnumerable<IPublishedContent> DescendantsOrSelf(this IEnumerable<IPublishedContent> parentNodes,string docTypeAlias)
    {
       
    return parentNodes.SelectMany(x => x.DescendantsOrSelf(docTypeAlias));
    }

    Cheers,

    Paul

Please Sign in or register to post replies

Write your reply to:

Draft