Umbraco newbie of course..
I have some code that returns a certain data type contents for a given node id which is detailed here:
umbraco API: trying to get the document type data for a given site node
That works fine, however I have to know the starting node i.e. in my case the site node id (multi-site umbraco installation).
I also know you can get the master root node via:
Umbraco – Finding Root Node in C#
My question is this…
From the backend API, is there anyway to dynamically get the current site node ID (first link)? this is so I don’t have to know it in advance. I think there is an option to get the site id from a querystring.. Page.Request.QueryString[“id”] however I am guessing this is returned if the page is a template page, however this is from a backend class?
Is there anyway? or I am barking up the wrong tree! ??
Any help would be appreciated!!
Assuming that all of your rootnodes are of the same document type, in razor you could do something like this:
which will search from the current node ‘up’ or ‘backwards’ until it gets to a nodetype of the type specified.
another way is available here:
http://our.umbraco.org/forum/developers/api-questions/20742-Getting-the-home-node-using-c