Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi!
Newbie question, I have a URL passed in the query string. From that URL I want to modify a property on a page.
How do I get a handle on the Document from the url?
I'm thinking something like this:
var url = "/path-of-document/";
var docId = <scene missing>
var document = new Document(docId);
Thanks!
-Evan
Split the URL on / and build an XPath statement to execute against the Umbraco XML cache, that's the easiest way. So for the URL: /my/web/page you'll get an XPath like this:
//*[@isDoc && @urlName='my']/*[@isDoc && @urlName='web']/*[@isDoc && @urlName='page']
(Syntax may not be 100% correct, I'm a coder, not a XPath person)
Cheers Slace. Makes sense, thanks for that.
I ended up taking another route, but I might need to give this a go later.
Have you seen this:
umbraco.library.GetXmlDocumentByUrl
?
I couldn't get that to work either?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How do I get the Document Id from a URL?
Hi!
Newbie question, I have a URL passed in the query string. From that URL I want to modify a property on a page.
How do I get a handle on the Document from the url?
I'm thinking something like this:
var url = "/path-of-document/";
var docId = <scene missing>
var document = new Document(docId);
Thanks!
-Evan
Split the URL on / and build an XPath statement to execute against the Umbraco XML cache, that's the easiest way. So for the URL: /my/web/page you'll get an XPath like this:
//*[@isDoc && @urlName='my']/*[@isDoc && @urlName='web']/*[@isDoc && @urlName='page']
(Syntax may not be 100% correct, I'm a coder, not a XPath person)
Cheers Slace. Makes sense, thanks for that.
I ended up taking another route, but I might need to give this a go later.
Have you seen this:
?
I couldn't get that to work either?
is working on a reply...