Copied to clipboard

Flag this post as spam?

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


  • Jesse Stopple 4 posts 94 karma points
    May 10, 2017 @ 14:13
    Jesse Stopple
    0

    pulling in content - high level guidance requested

    Looking for some high level guidance on getting my content working.

    I have a basic template set up, and am looking to pull one (or more) content objects, loop on them, and output the data.

    I have my master content object (MemberHome), and a child content object associated to it:document type

    The associated content has a few different fields that need to be output in specific places.

    My goal is to check for a specified number of these child content objects, loop through them, then build and output the required html and content. I'm looking for advice on how to get started, and what features/functions I should be using to facilitate this.

    Thanks in advance

  • Jesse Stopple 4 posts 94 karma points
    May 10, 2017 @ 17:09
    Jesse Stopple
    0

    I have made some progress. I'd like to update where I'm at and if anyone has suggestions or corrections I'm all ears.

    I created a "Partial View Macro" and referenced it inside a "Macro" using the MVC Partial View input area.

    Inside the primary template, I am referencing the Macro via:

    @Umbraco.RenderMacro("BabyMacro")

    Inside the partial view macro, I'm using a query to pull child content objects by name:

    var selection = CurrentPage.Site().Children("memberHomeMainNewsArticle").Where("Visible");

    I'm running a loop and using GetPropertyValue to output the content data as needed:

    @foreach(var item in selection){

        @item.GetPropertyValue("newsArticleTitle")
    
        @item.GetPropertyValue("publishedBy")
    
        @item.GetPropertyValue("textContent")
    
        @item.GetPropertyValue("leftAlignImage")
    }
    

    Any hints, suggestions, corrections greatly appreciated

Please Sign in or register to post replies

Write your reply to:

Draft