Umbraco - select node by url

I am having problems with Umbraco when trying to access node at this url.

I am trying to form an xpath request for selection on a URL, but I have no idea how to do this, and everything in their API is “dynamic”, so I am not able to dig a lot deeper for other methods.

The Document Link property in the Umbraco editor shows the path " / links / link-regions / link-region-1 / ". Its location in the editor is " / Data / Links / Link Regions / Communication Region 1 ".

I suspect it will look like this, but I will not work:

//*[@url='/links/link-regions/link-region-1/']

Basically, I want to know what I need to do to get the node by providing one of these values ​​and not the others. I tried to do this for several days to no avail, please help!

+4
source share
1 answer

If you are using Umbraco 4.11 or later, there is a new set of APIs that allow you to extract strongly typed content (as opposed to dynamic - which can be unpleasant when trying to evaluate types during debugging).

UmbracoContext.Current.ContentCache.GetByRoute(string url) should do what you want.

+14
source

Source: https://habr.com/ru/post/1546293/


All Articles