Copied to clipboard

Flag this post as spam?

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


  • Streety 358 posts 568 karma points
    May 14, 2014 @ 15:44
    Streety
    0

    Creating one collection from two MNTP on two child pages

    Hello I have a page with two child pages below. Both child pages have a Multi Tree Node Picker. Both these tree pickers are called the same name (pageNewsPicker).

    This is the code that works:

    if (CurrentPage.Children().Any())
    {
    foreach (var item in CurrentPage.Children)
    {
    var newsPicker = item.GetPropertyValue("pageNewsPicker");

    if (newsPicker != String.Empty )
    {

    var newsList = newsPicker.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
    var newsCollection = Umbraco.Content(newsList);

    foreach (var news in newsCollection)
    {

    @news.Name



    }

    }


    }
    }

    However as you may have suspected this approach is very limiting as its just outputting the results of the newsCollection twice, 2 objects for child page one and 2 objects for child page two

    The problem being I can't sort or filter as I would like accross all the items being returned.

    I want to be able to create one Collection object and insert both page (pageNewsPicker) objects into it. Then I can foreach all 4 objects and filter and sort et al.

    Apologies if these is fundamental and easy peasy. I am new to MVC and am tring to do this right.

    Any pointers would be good. Thanks

     

     

     

     

  • Streety 358 posts 568 karma points
    May 15, 2014 @ 09:57
    Streety
    0

    I suspect the object I need is DynamicNodeList.

    Can't find any syntax pointers

Please Sign in or register to post replies

Write your reply to:

Draft