|
|
 Rank: Devotee
Joined: 4/22/2008 Posts: 80 Location: Plymouth, UK
|
I have a custom datatype using umbraco user control wrapper which is used in both front and back end. In the backend I need to walk up the tree to find the closest node that has a specific property set and set that as the selected item in my datatype - any ideas?
I understand I can use umbraco.library.GetXmlNodeById(Request.QueryString["id"]) to get the current node but not sure where to go from here?
Any help would be appreciated.
Thanks, Simon
|
|
 Rank: Umbracoholic
Joined: 2/19/2007 Posts: 1,056 Location: Belgium
|
I suggest you use umbraco.cms.businesslogic.web.Document Fetch the current umbraco.cms.businesslogic.web.Document current = new umbraco.cms.businesslogic.web.Document((int)Request.QueryString["id"]); and then use a while loop to look for the closest node with the specific property set
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Umbracoholic
Joined: 2/19/2007 Posts: 1,056 Location: Belgium
|
loop will look something like umbraco.cms.businesslogic.web.Document parent = current.parent; while(parent.getProperty("propertyalias").value == null) { parent = parent.parent; }
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
 Rank: Newbie
Joined: 8/6/2006 Posts: 23 Location: Auckland New Zealand
|
Tim beat me to it. I was going to say use umbraco.cms.businesslogic.Content and use the parent property on that. But Document Inherits from Content so its the same thing really.
Level 2 Certified Umbraco Developer
|
|
 Rank: Devotee
Joined: 4/22/2008 Posts: 80 Location: Plymouth, UK
|
Tim, thanks for the pointer which has got me to a working solution. Code: Document currentDoc = new Document(Convert.ToInt32(Request.QueryString["id"]));
while (currentDoc.getProperty("Branch") == null) { currentDoc = new Document(currentDoc.Parent.Id); } currentDoc.Parent returns a CMSNode and not another document so my question now is how efficient is the above workaround and is there a better way of achieving the same?
|
|
 Rank: Newbie
Joined: 8/6/2006 Posts: 23 Location: Auckland New Zealand
|
From my little play around there doesnt seem to be a efficient way other than creating a new document from the CMSNode.Id.
Level 2 Certified Umbraco Developer
|
|
 Rank: Devotee
Joined: 4/22/2008 Posts: 80 Location: Plymouth, UK
|
Thanks for looking Peter
|
|
The forum has moved
This forum is no longer in use, so you can't reply to this message - please go to Our Umbraco
|
|
Guest |