Copied to clipboard

Flag this post as spam?

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

  • Sarah Marriott 2 posts 84 karma points
    Jan 08, 2019 @ 19:57
    Sarah Marriott

    Displaying Nested content


    I am new to Umbraco and just building my first website using v7.12.4

    I have become stuck trying to display nested content in my template. I have tried following the documentation here:

    However I am getting the following error:

    Compiler Error Message: CS1928: 'Umbraco.Web.Models.PartialViewMacroModel' does not contain a definition for 'GetPropertyValue' and the best extension method overload 'Umbraco.Web.PublishedContentExtensions.GetPropertyValue<T>(Umbraco.Core.Models.IPublishedContent, string)' has some invalid arguments


    Please see below an image of my document type

    Nested Content

    I have placed my code in a Partial View Macro File (I hope this is right) and can be seen here:

    @using Umbraco.Web
    @inherits Umbraco.Web.Macros.PartialViewMacroPage
        var items = Model.GetPropertyValue<IEnumerable<IPublishedContent>>("ideaLinks");
        foreach(var item in items)
            @Umbraco.Field(item, "method")

    Can anyone see where I may be going wrong?

    I have scoured the net for a solution, but to no avail - it must be something simple!



  • Søren Kottal 419 posts 2557 karma points MVP c-trib
    Jan 08, 2019 @ 20:58
    Søren Kottal

    Hi Sarah

    You don't have to place your code in a Partial View Macro File. You can put it in your document types template instead, or if you prefer a partial, a Partial View.

    You need to inherit from UmbracoViewPage, to have the IPublishedContent in Model.

    Also, I would advise against using @Umbraco.Field() for getting properties. Use Model.GetPropertyValue(), or ModelsBuilder.

  • Sarah Marriott 2 posts 84 karma points
    Jan 08, 2019 @ 21:13
    Sarah Marriott

    Hey Søren,

    Thanks so much for the quick reply - I've put the code in a Partial View (i didn't know about those!) and added the inherits and it works!

    Thanks again!

    This forum is invaluable :)


Please Sign in or register to post replies

Write your reply to: