In all the time I've been using Umbraco I can't believe I've never come across this before. Of course I can get the current site root given only a specific node Id, but it's ugly and brute force. So I get to ask a forum question:
In an ApiController (so I don't have UmbracoContext.Current.PublishedContentRequest, Model, etc...) what is the best (or a good) way to get the root node of a specific type for the current site given I have a multi domain instance?
I am passing the current node Id to the controller, and that is all I know about which site in this instance the Api call is coming from.
I'd love to have more insight...thank you in advance!
Get Site Root in ApiController with Multi-Root Site FIltering by Doc Type
In all the time I've been using Umbraco I can't believe I've never come across this before. Of course I can get the current site root given only a specific node Id, but it's ugly and brute force. So I get to ask a forum question:
In an ApiController (so I don't have
UmbracoContext.Current.PublishedContentRequest
,Model
, etc...) what is the best (or a good) way to get the root node of a specific type for the current site given I have a multi domain instance?I am passing the current node Id to the controller, and that is all I know about which site in this instance the Api call is coming from.
I'd love to have more insight...thank you in advance!
Hi Paul,
Since you got the id of the node, I would say xpath query. Something like this :
Dave
That's exactly it, thank you. That is much more elegant than what I had mangled without the XPath. For posterity, here's what I have:
is working on a reply...