I would start by suggesting that you drop the use of umbraco.NodeFactory. This method of retrieving nodes is now deprecated and won't be supported in future versions.
Instead I would recommend that you use UmbracoHelper with something along the lines of the following:
Umbraco.Web.UmbracoHelper helper = new Umbraco.Web.UmbracoHelper(UmbracoContext.Current);
var page = helper.TypedContentSingleAtXPath("//Qualifications");
foreach (var menuItem in page.Children)
{
<li>@menuItem.Name</li>
}
If you check the documentation, you will notice that you can also access other properties from your DocType via the .GetPropertyValue[<T>](string propertyAlias).
EDIT: The reason that your current implementation won't work is because GetNodeByXPath will always return an IEnumerable (even if there is only one item), hence the use of TypedContentSingleAtXPath above.
Loop through content in a Partial View
Hi folks,
I'm having trouble looping through content in a partial view. This is what I've done so far:
I can see that when the loop is hit that the children are being returned and I can see their properties:
But these properties aren't available to me in code:
I'm obviously missing something(!) any chance someone could fill me in on where I'm going wrong please?
thanks, Craig
Hi Craig,
I would start by suggesting that you drop the use of umbraco.NodeFactory. This method of retrieving nodes is now deprecated and won't be supported in future versions.
Instead I would recommend that you use UmbracoHelper with something along the lines of the following:
If you check the documentation, you will notice that you can also access other properties from your DocType via the
.GetPropertyValue[<T>](string propertyAlias)
.EDIT: The reason that your current implementation won't work is because
GetNodeByXPath
will always return anIEnumerable
(even if there is only one item), hence the use ofTypedContentSingleAtXPath
above.Gary
You, my friend, are one sexy mother!
That's driven me mental
is working on a reply...