@inherits Umbraco.Web.Macros.PartialViewMacroPage
@*
This snippet lists the items from a Multinode tree picker, using the pickers default settings.
Content Values stored as xml.
To get it working with any site's data structure, set the selection equal to the property which has the
multinode treepicker (so: replace "PropertyWithPicker" with the alias of your property).
*@
@{
if (Model.Content.HasValue("PropertyWithPicker"))
{
var bannerListValue = Model.Content.GetPropertyValue<string>("PropertyWithPicker");
var bannerList = bannerListValue.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
var bannerCollection = Umbraco.TypedContent(bannerList).Where(x => x != null);
foreach (var item in bannerCollection.Where(x => x.DocumentTypeAlias == "umbTextPage"))
{
<p>@item.Name</p>
}
}
}
With this code you are getting the items that are picked in the multi-node tree picker on the current page, and then I only pull out the items that uses the umbTextPage document type.
So what you need to do in the example above to get it working with your setup is to change this "PropertyWithPicker" so it match the alias of your picker.
After this you will also need to change "umbTextPage" so it match the alias of the category that you want to get.
How to find all nodes with a specific category from a Multi-Node Tree Picker ?
Hey guys,
My homepage is built up with three different categories:
All nodes are within one of these categories and now im having trouble finding all nodes with e.g. Travel as the category.
It is in C# and not XSLT
Can anyone explain how this is done?
Appreciate any solution or information about this problem
Hi Nicolai,
I think this can help you.
With this code you are getting the items that are picked in the multi-node tree picker on the current page, and then I only pull out the items that uses the umbTextPage document type.
So what you need to do in the example above to get it working with your setup is to change this "PropertyWithPicker" so it match the alias of your picker.
After this you will also need to change "umbTextPage" so it match the alias of the category that you want to get.
Hope this helps,
/Dennis
What if my categories are not on the current page? They are located at this location in my umbraco folder hierarchy:
Root/Folder/Categories/category
I found a solution with XSLT but I would really like to learn how to do this in a partial view.
Did you ever find a solution to this?
I'm sitting with the same problem
Im afraid not. I went with the XSLT solution.
If you come up with a solution, please share
is working on a reply...