Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Evan 40 posts 59 karma points
    Dec 14, 2010 @ 04:19
    Evan
    0

    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

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Dec 14, 2010 @ 05:37
    Aaron Powell
    0

    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)

  • Evan 40 posts 59 karma points
    Dec 14, 2010 @ 07:35
    Evan
    0

    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?

Please Sign in or register to post replies

Write your reply to:

Draft