Copied to clipboard

Flag this post as spam?

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


  • bh 408 posts 1395 karma points
    Mar 13, 2018 @ 14:04
    bh
    0

    Populate Partial View From Page Property

    I have a page Events. On my Events page I have a property EventsGrid. I would like to list the top 4 events from that EventsGrid in a Partial View that I can then replicate in multiple locations on the website.

    My question is how to parse the children of the Events Grid on the Events page within my Partial View?

    I'm thinking I start here:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<Events>
    

    If that's correct (which I'm not sure it is), I don't know how to get to the children of the property EventsGrid. EventsGrid is using a Doctype called wStationery.

    This is the code from my Events page:

    @if(Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("eventsGrid") != null){
        @Html.Partial("wStationery",Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("eventsGrid"))
    }
    

    I'm not even entirely sure what I'm trying to do is even possible.

    Umbraco v 7.6.4

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Mar 13, 2018 @ 14:11
    Michaël Vanbrabandt
    0

    Hi bh,

    what kind of property is EventsGrid? Is this a MultiNode TreePicker?

    Are the Event Items direct children of your page Events?

    Maybe it would be handy to show us a preview of your content structure.

    Thanks.

    /Michaël

  • bh 408 posts 1395 karma points
    Mar 13, 2018 @ 14:33
    bh
    0

    Q: what kind of property is EventsGrid? Is this a MultiNode TreePicker? A: Here's the hierarchy of Doctypes at play here...

    Events (page) >

    Events Grid (property of Events page) >

    wStationery (property editor for Events Grid) >

    wStationeryGrid (property of wStationery) >

    wGrid (property editor for wStationeryGrid) >

    wGridGridItems (property of wGrid) >

    wGridItem (property editor for wGridGridItems)

    Q: Are the Event Items direct children of your page Events? A: Unfortunately no. This was my first umbraco site...i wasn't that advanced at the time. I've since learned how to set up parent/children pages like that, but not in this case.

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Mar 16, 2018 @ 08:32
    Alex Skrypnyk
    0

    Hi Ben

    It's not clear what property editors you are using and how it looks in the umbraco back-office

    Can you show Umbraco back-office? Property editors and hierarchy

    /Alex

  • bh 408 posts 1395 karma points
    Mar 16, 2018 @ 13:17
    bh
    0

    Here's the DocType for my Community Events page (note the wStationery property editor): enter image description here

    Here's the DocType for wStationery (note the wGrid property editor): enter image description here

    Here's the DocType for wGrid (note the wGridItem property editor): enter image description here

    Here's the DocType for wGridItem: enter image description here

    Hope that clears up the hierarchy of DocTypes/property-editors.

  • bh 408 posts 1395 karma points
    Mar 16, 2018 @ 14:04
    bh
    0

    To clarify the ask, i'm hoping to pull in data from the first 4 wGridItems (there are multiple wGridItem in the containing wGrid), into a partial view that I can then duplicate in multiple locations throughout the site.

  • bh 408 posts 1395 karma points
    Mar 20, 2018 @ 18:59
    bh
    0

    @AlexSkrypnyk any suggestions?

Please Sign in or register to post replies

Write your reply to:

Draft