Copied to clipboard

Flag this post as spam?

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


  • Nathan 67 posts 146 karma points
    Sep 03, 2014 @ 10:31
    Nathan
    0

    Get fields from Archetype based on current page

    In my Content section I have a property editor (Archetype) that allows to set content for the site independently from the content tree. It looks like this:

    I need to display only the sub categories from one category based on what page I'm currently on. What I have now is:

    var catItems = Umbraco.Content(1123).categoryItem; //get the Set Content property editor from Content Section
    
    foreach (var item in catItems)
    {
        foreach (var sub in item.GetValue<ArchetypeModel>("subCatItem"))
        {
            <div class="tbl_dt">
                <p class="offerName">@sub.GetValue("offerName")</p>
                <p class="departurePort">@sub.GetValue("departurePort")</p>
            </div>
        }
    
    

    }

    This is displaying all the sub category items from all categories. It should display only the sub categories based on current page. How can I make the connection between current page and the sub category item? Or it is best to stick with the property editor in the content tree pages?

Please Sign in or register to post replies

Write your reply to:

Draft