If I want to edit 'about-Us.aspx' for example I need to convert 'about-Us.aspx' to '1549' to open the editor on that page.
I tried using GetXmlDocumentByUrl but I have no idea. string GetNodeID_ByUrl(string nodeURL) { try { return umbraco.library.GetXmlDocumentByUrl(nodeURL).Current.GetAttribute("Id", ""); } catch { return"not" } }
How to get ID from URL
Does anyone know an easy way to get the ID of a file given the URL?
If it helps to know why I want the Id... I'm trying to do deep linking into the Umbraco editor. For example a typical deep link looks like this.
http://www.mySite.com/umbraco/umbraco.aspx?app=content&rightAction=editContent&id=1549#content
If I want to edit 'about-Us.aspx' for example I need to convert 'about-Us.aspx' to '1549' to open the editor on that page.
I tried using GetXmlDocumentByUrl but I have no idea.
string GetNodeID_ByUrl(string nodeURL)
{
try
{
return umbraco.library.GetXmlDocumentByUrl(nodeURL).Current.GetAttribute("Id", "");
}
catch
{
return "not"
}
}
Thanks!
Hi,
I don't quite understand why you need to do this - where are you getting the URL from, you should be able to get the ID from the same place, no?
If not, you could try a helper method in uQuery from uComponents - GetNodeByUrl(string url), and do something like:
Not quite sure on the format the URL needs to be in, perhaps "/about-us.aspx"
-Tom
The URL is comming from a client side javascript. I'm developing a browser based way of navigating through the Umbraco editor.
What references to I need to add to my project for uComponents to work?
Just add a reference to uComponents.Core.dll which you can get from the package or build from the source.
-Tom
is working on a reply...