Get all currently published nodes of a root document type
Hi there, in C# I need to retrieve a list of all published documents / nodes whose document type is a descendent of the document type "SiteSettings".
What's the best way to go about this?
I have got as far as...
foreach (var content in Document.getContentOfContentType(DocumentType.GetByAlias("SiteSettings")).Union( Document.getContentOfContentType(DocumentType.GetByAlias("Homepage")).Union( Document.getContentOfContentType(DocumentType.GetByAlias("themedPage")).Union( Document.getContentOfContentType(DocumentType.GetByAlias("modulePage")))))) { // do something }
I haven't yet found a good way to query for a root document type, so here I'm querying for the root and all it's descendent types explicitly. However this appears to produce some duplicates and unpublished items.
btw: if yoou use the Documents you are getting all content nodes also the unpublished ones and you are creating many many db calls. I would recommend going to the umbraco.presentation.NodeFactory.Node Namespace which only returns published content and from the memmory not from the db.
Get all currently published nodes of a root document type
Hi there, in C# I need to retrieve a list of all published documents / nodes whose document type is a descendent of the document type "SiteSettings".
What's the best way to go about this?
I have got as far as...
I haven't yet found a good way to query for a root document type, so here I'm querying for the root and all it's descendent types explicitly. However this appears to produce some duplicates and unpublished items.
thanks for your help
Kris
This would be a perfect scenario to use LinQ2Umbraco. Take a look into the sessions of Aaron: http://aaron-powell.com/training-videos
hth, Thomas
btw: if yoou use the Documents you are getting all content nodes also the unpublished ones and you are creating many many db calls. I would recommend going to the umbraco.presentation.NodeFactory.Node Namespace which only returns published content and from the memmory not from the db.
hth, Thomas
is working on a reply...