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
Afternoon All,
just wondernig if you can have a look at this please, Trying to load nested content within nested content.
seem to able to see the first level but the second doesn't seem to locate any information:
@inherits Umbraco.Web.Mvc.UmbracoViewPage @if (Model.HasValue("parts")) { var items = Model.Value<IEnumerable<IPublishedElement>>("parts"); foreach(var item in items) { <h3>@item.GetProperty("title").Value()</h3> <div> @{ var secondItems = item.Value<IEnumerable<IPublishedElement>>("questions"); if(secondItems != null) { <h3>@item.GetProperty("sectionNumber").Value()</h3> } } </div> } }
I keep on getting the error: Object reference not set to an instance of an object.
here is the nested content: incase i'm entering the wrong details into the second one
Hi, well you should probably loop through you're secondItems list. Like this:
var secondItems = item.Value<IEnumerable<IPublsihedElement>>("questions"); if(secondItems.Any()){ foreach(var secondItem in secondItems){ <h3>@secondItem.GetProperty("sectionNumber").Value()</h3> } }
Just getting error: The type or namespace name 'IPublsihedElement' could not be found (are you missing a using directive or an assembly reference?)
This is what I've put in to get that error
@inherits Umbraco.Web.Mvc.UmbracoViewPage @if (Model.HasValue("parts")){ var items = Model.Value<IEnumerable<IPublishedElement>>("parts"); foreach(var item in items) { <h3>@item.GetProperty("title").Value()</h3> <div> @{ var secondItems = item.Value<IEnumerable<IPublsihedElement>>("questions"); if(secondItems.Any()){ foreach(var secondItem in secondItems){ <h3>@secondItem.GetProperty("sectionNumber").Value()</h3> } } } </div> } }
I've always used this for nested content as well:
@using Umbraco.Web.Models
The specific error is due to a typo:
Use IPublishedElement instead of IPublsihedElement
Adding that doesnt seem to make any difference
infact it now working, seem to be issues when putting the code in via partial views.
remove the view and added directly to the template and showing fine now.
thanks everyone for the help
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Nested content within nested content
Afternoon All,
just wondernig if you can have a look at this please, Trying to load nested content within nested content.
seem to able to see the first level but the second doesn't seem to locate any information:
I keep on getting the error: Object reference not set to an instance of an object.
here is the nested content: incase i'm entering the wrong details into the second one
Hi, well you should probably loop through you're secondItems list. Like this:
Just getting error: The type or namespace name 'IPublsihedElement' could not be found (are you missing a using directive or an assembly reference?)
This is what I've put in to get that error
I've always used this for nested content as well:
The specific error is due to a typo:
Use IPublishedElement instead of IPublsihedElement
Adding that doesnt seem to make any difference
infact it now working, seem to be issues when putting the code in via partial views.
remove the view and added directly to the template and showing fine now.
thanks everyone for the help
is working on a reply...