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:39
    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?

  • IanS 22 posts 65 karma points
    Sep 09, 2014 @ 17:51
    IanS
    0

    Have you tried changing your first line to:

    var catItems =Model.Content.GetPropertyValue<ArchetypeModel>("categoryItem");
Please Sign in or register to post replies

Write your reply to:

Draft