I'm trying to generate an a to z listings from the children of 2 nodes.
The nodes at root are "Home" and "A to Z Entries folder".
My existing script listed the Home node correctly:
@if (!string.IsNullOrEmpty(Request.QueryString["letter"]))
{
var letter = Request.QueryString["letter"].ToUpper().Substring(0,1) ;
var root = Model.Content.AncestorOrSelf(1);
var nodes = root.DescendantsOrSelf().Where( x => x.IsVisible() && x.Name.ToUpper().StartsWith(letter) ).OrderBy("Name");
<h2>@letter</h2>
if ( nodes.Any() )
{
<ul>
@foreach(var node in nodes)
{
<li><a href="@node.Url">@node.Name</a></li>
}
</ul>
}
}
I was advised to look at TypedContentAtRoot()
I can get the root nodes to appear in the a to z listing but not the children. I need to get the children specifically of "Home" and "A to Z Entries folder"
My test code:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@if (!string.IsNullOrEmpty(Request.QueryString["letter"]))
{
var letter = Request.QueryString["letter"].ToUpper().Substring(0,1);
<h2>@letter</h2>
<ul>
@foreach (var child in Umbraco.TypedContentAtRoot().Where( x => x.IsVisible() && x.Name.ToUpper().StartsWith(letter)).OrderBy("Name"))
{
<a href="@child.Url">@child.Name</a>
}
</ul>
}
A to Z search multiple nodes at root
I'm trying to generate an a to z listings from the children of 2 nodes.
The nodes at root are "Home" and "A to Z Entries folder".
My existing script listed the Home node correctly:
I was advised to look at TypedContentAtRoot()
I can get the root nodes to appear in the a to z listing but not the children. I need to get the children specifically of "Home" and "A to Z Entries folder"
My test code:
Any help would be much appreciated.
Cheers
Rich
Managed to get this working with the following code:
is working on a reply...