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.
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.
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.
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.
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
is working on a reply...