Copied to clipboard

Flag this post as spam?

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


  • René Andersen 238 posts 684 karma points
    Apr 28, 2015 @ 14:44
    René Andersen
    0

    Get parent Url and Name Multinode Treepicker

    Hi,

    I am using the Multinode Treepicker to choose which items to show and that works fine but how do I get the name and url on the item's parent (marked with green below).

    I am using this standard code which works fine, but I also need to show the name  and url for the item parent:

    @{
    var bannerList = CurrentPage.banner.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

    var bannerCollection = Umbraco.Content(bannerList);
    foreach (var item in bannerCollection)
    {
    @item.Name
    }
    }

    Thanks in advance!

    // René

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Apr 28, 2015 @ 15:08
    Dennis Aaen
    100

    Hi René

    I think that you could do something like this to achieve what you want. First I think you need to find the data node, and from there loop though the children, and pick only the cast and series document type.

    @{ 
        var dataItem = Umbraco.ContentAtRoot().DescendantsOrSelf("DataDocumentTypeAlias").FirstOrDefault();
    }
    <ul>
        @* OrderBy() takes the property to sort by and optionally order desc/asc *@
       
        @foreach (var page in dataItem.Children("Cast/Scenes document type").Where("Visible"))
        {
            <li><a href="@page.Url">@page.Name</a></li>
        }
    </ul>

    Remember to change the document type alias so it match your case.

    Hope this works, or at least give your some idea on how you could do it. If you have other questions about this don't hesitate to ask again, and I will try to help,

    /Dennis

  • René Andersen 238 posts 684 karma points
    Apr 28, 2015 @ 19:27
    René Andersen
    1

    Hi Dennis

    That was just what I was looking for.

    Now I am using your code and just added:

    @page.parent.Name

    Thanks!

    // René

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Apr 28, 2015 @ 19:33
    Dennis Aaen
    0

    Hi René

    You're welcome, glad that I could help you to find a solution.

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft