|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 738 Location: Belgium
|
Hey Guys, I'm working on a usercontrol and i want to loop through the entire content tree. How can I do that ? I Thought I could do it like this Code: Document root = new Document(-1); if (root.HasChildren) { loopchildren(root, alias); }
Code: private void loopchildren(Document ParentDocument, string alias) { Label1.Text += ParentDocument.Children.Length.ToString(); foreach (Document tempDocument in ParentDocument.Children) { Label1.Text += tempDocument.Id.ToString(); if (tempDocument.Id > 0) { if (tempDocument.ContentType.Alias == alias) {
// Move(tempDocument); Label1.Text += tempDocument.Id.ToString() + "<br/>"; }
if (tempDocument.HasChildren) { loopchildren(tempDocument, alias); } } } }
But that doesn't seem to work.
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
Rank: Devotee
Joined: 9/5/2007 Posts: 65
|
Look here... http://www.umbraco.org/documentation/books/what's-new-in-v3/new-feature-nodefactory-as-datatable-objectOr consider using... library.GetXmlAll(); ...that returns the whole content tree in the standard umbraco XML format. Theres othed library.Get***** functions to return say the XML for the current noade and the like. Enjoy!
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 738 Location: Belgium
|
Thanks for the reply, I considered using the nodefactory but does it also return the nodes that are not published ?
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 738 Location: Belgium
|
The nodefactory (in the umbraco.presentation.nodeFactory namespace) is a wrapper for the in-memory XML for much easier access to published data from .NET. I need all data , published and not published. Any Idea ?
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 597 Location: Bad Homburg, Germany
|
Then use the document in umbraco.cms.businesslogic.web eg: umbraco.cms.businesslogic.web.Document doc = new umbraco.cms.businesslogic.web.Document(id); doc.Published, doc.Children, etc... hth, Thomas
• 2007/2008 MVP • www.thoehler.com • Bad Homburg, Germany
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 738 Location: Belgium
|
Yup that is what i tried, but how can i get the entire structure, i thought if I used -1 as id it returned the root document but that doesn't seem to work
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 597 Location: Bad Homburg, Germany
|
Sorry, didn't read the whole thread. Use umbraco.cms.businesslogic.web.Document.GetRootDocuments to get a list of all root documents of the backend and then iterate through the structure by document.Children... hth, Thomas
• 2007/2008 MVP • www.thoehler.com • Bad Homburg, Germany
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 738 Location: Belgium
|
Yup that did the trick. Didn"t notice the method. Thanks !
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
|
Guest |