Could someone tell me if it's possible to loop through all of the children of a node using the ContentService API please?
For instance what I'm trying to do is loop through every child of a parent node (id 1055) and check it's UpdateDate property.
Using Nodes I can loop through the node.Children collection but I can't seem to find one for the ContentServive.
This is what I have to get the Parent Node.
var contentService = new ContentService(); var content = contentService.GetById(1055); int myDate = Int32.Parse(content.UpdateDate.DayOfYear.ToString());
But having got this I'd like to loop through the children.
Loop through children using the ContentService
Hi folks.
Could someone tell me if it's possible to loop through all of the children of a node using the ContentService API please?
For instance what I'm trying to do is loop through every child of a parent node (id 1055) and check it's UpdateDate property.
Using Nodes I can loop through the node.Children collection but I can't seem to find one for the ContentServive.
This is what I have to get the Parent Node.
But having got this I'd like to loop through the children.
Could anybody help please?
thanks,
Craig
What's about this one.
Hi Jivan,
Thanks but the Umbraco.Core.Models.IContent doesn't contain a definition for 'Children'
Craig
Sussed it.
var contentService = new ContentService();
string myString = "";
var cPages = contentService.GetChildren(1055);
foreach (var item in cPages)
{
//Do stuff in here
}
All good!
Anyway, You found the ans.
There is a def. for "Children", you may missing some stuff. You can compare with this one
is working on a reply...