I am new to Umbraco and have a page Content structure like this:
Home - Models - - Model 1 - - Model 2 - - Model 3 About us Contact Us
On the Home page I want to show the names and descriptions of Model 1, Model 2 and Model 3. These three models have a document type of alias 'umbModelType'
(Note: I think it's the alias but the doc type labels it as 'Alternative link' - why? :) )
After some searching I have tried the Razor script below but get this error:
Errors in Razor select by document type
Hi
I am new to Umbraco and have a page Content structure like this:
Home
- Models
- - Model 1
- - Model 2
- - Model 3
About us
Contact Us
On the Home page I want to show the names and descriptions of Model 1, Model 2 and Model 3. These three models have a document type of alias 'umbModelType'
(Note: I think it's the alias but the doc type labels it as 'Alternative link' - why? :) )
After some searching I have tried the Razor script below but get this error:
'Error loading MacroEngine script (file: Homepage-modellist.cshtml)'
@inherits umbraco.MacroEngines.DynamicNodeContext
<ul>
@foreach (var item in @Model.AncestorOrSelf("umbModelType").Where("umbracoNaviHide != true"))
{
<li>
<h2><a href="@item.Url">@item.Name</a></h2>
@item.modelDescription
</li>
}
</ul>
I also tried this script from another source:
@inherits umbraco.MacroEngines.DynamicNodeContext
// Get root node:
var root = Model.AncestorOrSelf();
// Get all descendants, filter by type:
var nodes = root.Descendants("umbModelType");
// Loop through the filtered nodes, displaying the properties:
<ul>
@foreach (var node in nodes)
{
<li>
<h2>@node.Name</h2>
@node.modelDescription
</li>
}
</ul>
This script above threw this error when I saved it in Umbraco:
"error CS0103: The name 'nodes' does not exist in the current context"
Any help and pointers would be much appreciated. Thanks in advance.
Kevin
is working on a reply...