Copied to clipboard

Flag this post as spam?

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


  • Rob 22 posts 133 karma points
    Aug 31, 2020 @ 16:12
    Rob
    0

    In Umbraco 8 I am trying to make a single collection from multiple categories for filtering, is this possible.

    I have a page which has children.

    Each of these children has a multinode picker that selects a collection of items. Each of these node pickers point to a parent node with children... I want to just get at these children in one go

    I would like to create a selection of just the possible children so that collection can be filtered by price.

    The very long way round to get to each child is as follows. (This is just my test list to make sure I can get to them at all)

    @{ var selection = Model.Children.Where(x => x.IsVisible()).ToArray(); }
     @if (selection.Length > 0){
     <ul>
       @foreach (var item in selection){
        if(item.HasValue("categoryCollections")){
        @foreach(var catsel in item.Value<IEnumerable<IPublishedContent>>("categoryCollections")){
            if(catsel.Children.Any()){
            var prodselection = catsel.Children.Where(x => x.IsVisible()).ToArray();
            <p>Has Children</p>
            <ul>
                @foreach(var productItem in prodselection){
                <li><a href="@productItem.Url">@productItem.Name | @productItem.Value("priceGBP")</a></li>}            
            </ul>}}}}}
    

    Is there a way to create a selection of only the productItem nodes from one query, so I can organise them by price ?

  • Dee 118 posts 338 karma points
    Sep 01, 2020 @ 18:44
    Dee
    100

    Hey Rob,

    isn't it possible to do something like

    var childItems = Model.Children.Select(x => x.YourMultiNodePicker.Items.Select(p => p.Parent.Children)).Where(w => w.Price == ...) ? 
    

    I'm not sure what property the multi node picker uses, if its items or something else, but I guess something like this is what you are looking for?

    Dee

  • Rob 22 posts 133 karma points
    Sep 02, 2020 @ 13:49
    Rob
    0

    Works a treat thanks

Please Sign in or register to post replies

Write your reply to:

Draft