Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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:https://our.umbraco.com/Documentation/Getting-Started/Backoffice/Property-Editors/Built-in-Property-Editors/Nested-Content
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
I have placed my code in a Partial View Macro File (I hope this is right) and can be seen here:
var items = Model.GetPropertyValue<IEnumerable<IPublishedContent>>("ideaLinks");
foreach(var item in items)
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!
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.
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!
This forum is invaluable :)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted