Copied to clipboard

Flag this post as spam?

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


  • Patrick 10 posts 33 karma points
    Mar 01, 2011 @ 09:19
    Patrick
    0

    Unpublish nodes and get node id by path

    Hi,

    I am trying to get a node ID by URL, but can't find any API for doing it.

    I saw this post: http://our.umbraco.org/forum/developers/api-questions/6007-Get-node-by-path

    And tried the umbraco.library.GetXmlNodeByXPath method, but it only works for published nodes because it queries the cached file.

    What I am trying to do is to create a shortcut button to switch nodes between 2 languages

    Our content tree structure is like this

    en

    |- aaa

    de

    |- aaa

    If the node /de/aaa/ is not published, I cannot get node ID with the GetXmlNodeByXPath method. Is there other API calls to do it? Thanks.

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Mar 01, 2011 @ 11:47
    Tim
    2

    If the node isn't published, you wouldn't be able to link to it on the front end. Is the button for the back office?

    You could look at the relationship API, that would allow you to relate the two pages together and get the related pages using that API. I think that would work regardless of whether the page was published.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 01, 2011 @ 14:48
    Tom Fulton
    0

    Hi,

    I would think you would want to only work with published nodes, since unpublished ones won't have a URL?

    To get a node from the URL, uQuery from uComponents has a GetNodeByUrl(string) method that might work for you.

    Another option, check out Daniel Bardi's post here - he posted a snippet of a "path converter" to find the same page in a different part of the tree based on its path.

    Those being said, Tim's suggestin of using the Relationship API is probably best/easiest.  I have done this and it works great.

    Thanks,
    Tom

     

Please Sign in or register to post replies

Write your reply to:

Draft