Im trying to render nested content from a specific node on a different page.
The code is a partial
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
var source = @Umbraco.Content(1056);
var items = source.GetPropertyValue<IEnumerable<IPublishedContent>>("sponsorer");
}
<div>
@foreach(var item in items) {
<p>@item.Name</p>
}
</div>
I get the error "Parser Error Message: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup."
if i remove "<IEnumerable<IPublishedContent>>" i can get the loop of nested content nodes, but can't render property values, only the name of each nested content node.
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@{
var source = @Umbraco.TypedContent(1056);
var items = source.GetPropertyValue<IEnumerable<IPublishedContent>>("sponsorer");
}
<div>
@foreach(var item in items) {
<p>@item.Name | </p>
}
</div>
Still getting: "Parser Error Message: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup."
If i remove <IEnumerable<IPublishedContent>> now i get an erro saying "Compiler Error Message: CS1579: foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'"
This sounds like a real cop out answer, but I've had this before and basically, it had gotten confused within the file. I resolved it by re-creating the partial view and typing the code out again.
Rendering nested content from another page
Im trying to render nested content from a specific node on a different page. The code is a partial
I get the error "Parser Error Message: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup."
if i remove "
<IEnumerable<IPublishedContent>>
" i can get the loop of nested content nodes, but can't render property values, only the name of each nested content node.Hi Claus,
Try swapping
@Umbraco.Content
with@Umbraco.TypedContent
- as that will give you a strongly-typed object, rather than a dynamics one.Cheers,
- Lee
Still getting: "Parser Error Message: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup."
If i remove
<IEnumerable<IPublishedContent>>
now i get an erro saying "Compiler Error Message: CS1579: foreach statement cannot operate on variables of type 'object' because 'object' does not contain a public definition for 'GetEnumerator'"When you get the
Parser Error Message
error... does it give any line numbers?I can't spot anything immediately obvious from your code snippet.
This sounds like a real cop out answer, but I've had this before and basically, it had gotten confused within the file. I resolved it by re-creating the partial view and typing the code out again.
Fixed it
its was the "@" in @Umbraco.TypedContent(1056)... Should be Umbraco.TypedContent(1056)
is working on a reply...