Copied to clipboard

Flag this post as spam?

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


  • Conor 4 posts 74 karma points notactivated
    Sep 13, 2017 @ 14:12
    Conor
    0

    Searching for child nodes based on their tags

    Hey, I'm new to Umbraco and hoping somebody could help me with this issue.

    I have a parent page, 'Our Products'. This page has the page 'Product Page' set as it's child page. This 'Product Page' holds data about a product such as it's title, description, and tags which will be used for search functionality.

    I'm currently editing the code within the 'Our Products' page to try and retrieve some products with specific tags. This is the code I've tried to create so far.

        @{
        var searchTagsCriteria = "Tag1";
    
        var selection = Model.Content.Site().FirstChild("ourProductsPage").Children()
                            .Where(x => x.IsVisible())
                            .Where(x => x.GetPropertyValue<IEnumerable<string>>("productType").Contains(searchTagsCriteria));
    }
    
    <ul>
        @foreach(var item in selection){
            <li>
                <a href="@item.Url">@item.Name</a>
            </li>
        }
    </ul>
    

    This doesn't cause any compilation error, although it doesn't produce any results. I know that one of my products has a tag 'Tag1', so why can't I see this? I have a feeling I'm doing something wrong getting the tags correctly, but I'm not sure how to advance.

    Any guidance is appreciated.

Please Sign in or register to post replies

Write your reply to:

Draft