Recursively get all umbraco content, also unpublished, like the content tree
Hi,
I'm speaking about umbraco 6.x, but maybe the logic is similar for umbraco 7, so even who is using umbraco 7 can help to answer this?
I'd like to create a report containing all the umbraco nodes, also the unpublished ones (the "documents").
Umbraco shows those already, in the Content section.
So maybe you can point me out to the umbraco source code, where the content tree is generated and I may re-use the same code/logic in my report.
Or should this be as easy as using the Enumerating documents API Reference examples? If yes sorry for asking, but I wanted to be sure not to reinvent the wheel, when there is alrady some code available... ;-)
What I want to achieve is: find some code that "prints" (or even better: that adds to a list of objects, containing all the node basic information such as: node id, creation date, documenttypealias etc. and of course the node properties, so that I can implement my logic to display the node title or node heading depending on the documenttypealias) the above structure (that I already see in the umbraco backend, when I click on "Content" from the Content section.
In umbraco backend, what is unpublished is displayed in grey.
As I have thousands of published and unpublished nodes, I'd like to find an efficient algoryhtm to do the job. I mean something really fast that can scale for my scenario of thousands of pages.
Hope it's clear what I want to achieve... of course I can try on my own but I wanted to see if soembody has some code to share already.
No with "prints" I mean also a console.writeline for demonstration purposes. Better would be to create a list of objects.
Say List of type "NodeObject" with following properties:
Node/Document (the node itself, but I guess it has to be a "document" as it can be published or unpublished)
List of type Node/Document (in case there are children)
Then I could use this list and loop it to generate my report.
Actually "report" is something generic. It can be a page to display an overview of all pages of my umbraco website, or it can be a sitemap, or even a report.
I already have a system to generate such a thing, but it's damn slow and it doesn't scale, so I'd like to see what you guys suggest here.
thanks for pointing me to Examine, I guesss I'll give it a try and compare the results with the umbraco api (to see it really has a bad performance in my scenario).
Recursively get all umbraco content, also unpublished, like the content tree
Hi,
I'm speaking about umbraco 6.x, but maybe the logic is similar for umbraco 7, so even who is using umbraco 7 can help to answer this?
I'd like to create a report containing all the umbraco nodes, also the unpublished ones (the "documents").
Umbraco shows those already, in the Content section.
So maybe you can point me out to the umbraco source code, where the content tree is generated and I may re-use the same code/logic in my report.
Or should this be as easy as using the Enumerating documents API Reference examples? If yes sorry for asking, but I wanted to be sure not to reinvent the wheel, when there is alrady some code available... ;-)
Thank you for letting me know & cheers
Hi Firepol,
What are you trying to achieve here?
Thanks,
Charlie
Say my Content has the following 3 nodes (as example, in reality I have many more - thousands) and subnodes:
Node 1
-Lorem (not published)
--Lorem 1
--Lorem 2
--Lorem 3
-Ipsum
--Ipsum1
--Ipsum2
--Ipsum3
Node 2
-Foo
-Bar (not published)
--Bar1
--Bar2
...
Node 3
-Stuff
--Stuff1 (not published)
--Stuff2
...
-Example (not published)
--Example1
--Example2
..
What I want to achieve is: find some code that "prints" (or even better: that adds to a list of objects, containing all the node basic information such as: node id, creation date, documenttypealias etc. and of course the node properties, so that I can implement my logic to display the node title or node heading depending on the documenttypealias) the above structure (that I already see in the umbraco backend, when I click on "Content" from the Content section.
In umbraco backend, what is unpublished is displayed in grey.
As I have thousands of published and unpublished nodes, I'd like to find an efficient algoryhtm to do the job. I mean something really fast that can scale for my scenario of thousands of pages.
Hope it's clear what I want to achieve... of course I can try on my own but I wanted to see if soembody has some code to share already.
Hi, Thanks,
When you say prints?
Do you write to a csv or something?
Charlie
No with "prints" I mean also a console.writeline for demonstration purposes. Better would be to create a list of objects.
Say List of type "NodeObject" with following properties:
Then I could use this list and loop it to generate my report.
Actually "report" is something generic. It can be a page to display an overview of all pages of my umbraco website, or it can be a sitemap, or even a report.
I already have a system to generate such a thing, but it's damn slow and it doesn't scale, so I'd like to see what you guys suggest here.
Ok, what sort of report are you trying to generate.
If you don't need to worry about performance you could just use the umbraco API
// Get the home node in a variable
//Foreach around the homenode descendants
//Get the properties you need from each node
//write to file / create report.
If you do need to worry about performance, you should use Examine.
http://umbraco.com/follow-us/blog-archive/2011/9/16/examining-examine.aspx
// Do a search using examine // Do a foreach around each item you get from Examine //Get the properties //write to file / create report?
Is that the sort of thing you are after?
Hi Charles,
thanks for pointing me to Examine, I guesss I'll give it a try and compare the results with the umbraco api (to see it really has a bad performance in my scenario).
I'll come back here with what I find.
Yea if you want performace Examine is the way to go. Good luck, let us know how you get on :)
Examine has an issue in wich it fails to reindex unpublished nodes see https://our.umbraco.org/forum/developers/extending-umbraco/35524-Examine-RebuildIndex-not-indexing-unpublished-nodes
Therefore I am looking at other options.
is working on a reply...