Copied to clipboard

Flag this post as spam?

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


  • John C Scott 473 posts 1183 karma points
    Nov 01, 2011 @ 00:16
    John C Scott
    0

    uComponents uQuery Document Extension

    I'm trying to find the next sibling of a document. It needs to be a document and not a node. I've seen that there is an extension method within uComponents that seems to do exactly that,

    IEnumerable<Document> GetFollowingSiblingDocuments()  [v2.3]

    However there's a few things I don't really understand. I've downloaded 2.2. package beta 3, I had 2.0 previously. I've referenced the uComponents.Core dll in my solution.

    For starters does [v2.3] mean it's not in the current release 2.2

    What is an extension method, does it mean I can just write

    using umbraco.cms.businesslogic.web;
    using umbraco.BusinessLogic;
    using uComponents.Core.uQueryExtensions;
    Document docPub = new Document(1234);
    xxx = docPub.GetFollowingSiblingDocuments();

    and how do i express xxx?

    Sorry for not really getting it.


  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Nov 01, 2011 @ 00:48
    Lee Kelleher
    0

    Hi John,

    Don't worry too much about the uComponents version numbers - truth is that we've been in beta with v2.2 for so long that everything thinks it's an official release (which it's not - that's v2.1) ... but it's stable enough that people are using v2.2 betas on production sites (e.g. me).  I digress.

    By calling "docPub.GetFollowingSiblingDocuments()", you will get a collection of Documents back, which you'll only need the first one.

    List<Document> siblings = docPub.GetFollowingSiblingDocuments();
    Document nextSibling = siblings[0];

    or if you reference System.Linq, then you could try calling FirstOrDefault directly?

    Document nextSibling = docPub.GetFollowingSiblingDocuments().FirstOrDefault();

    Cheers, Lee.

Please Sign in or register to post replies

Write your reply to:

Draft