Copied to clipboard

Flag this post as spam?

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


  • Nso 18 posts 87 karma points
    Jul 24, 2018 @ 07:51
    Nso
    0

    Query

        @{
        var selection2 = Model.Content.Site().FirstChild("specialitasaink").FirstChild("termekKontener").Children("termekElem")
                            .Where("fooldaliMegjelenites");
    }
    
    @{
        var selection3 = Model.Content.Site().FirstChild("specialitasaink").FirstChild("termekKontener").Children("termekElem")
                            .Where("fooldaliMegjelenites");
    }
    

    Hey, I would like to ask for help. I want to query with selection2 the first item, an with selection3 the other items except the first. How can I do this?

  • Marc Goodson 1451 posts 9716 karma points MVP 5x c-trib
    Jul 25, 2018 @ 00:32
    Marc Goodson
    1

    Hi Nso

    If I understand correctly would this work for you?

    @{
    var allSelections = Model.Content.Site().FirstChild("specialitasaink").FirstChild("termekKontener").Children("termekElem")
                            .Where("fooldaliMegjelenites");
    
    var firstSelection = allSelections.FirstOrDefault();
    var remainingSelections = allSelections.Skip(1);
    
    }
    

    You might find better performance in writing the first selection of items with XPath, eg

    var allSelections = Umbraco.TypedContentAtXPath("root/homePage/specialitasaink/termekKontener/termekElem/fooldaliMegjelenites[@isDoc]"); (or similar depending on the xml in your published umbraco.config file)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies