Is there a way to check if a node exists by its url say like:
getNodeByUrl(string URL) i ask as i have a site that will always have an English version of a document, but the user can select a region by a dropdown so when the links get written out via niceurl i want to know if another version exists so:
/en/mypage/
could be
/fr/mypage/
public static string NiceURLWithLocation(int nodeId) {
string url = umbraco.library.NiceUrl(nodeId);
if (HttpContext.Current.Session["LOCATION"] != null) { if (url.IndexOf("/en/") != -1) {
How ro check a node exists by URL
Hi,
Is there a way to check if a node exists by its url say like:
getNodeByUrl(string URL) i ask as i have a site that will always have an English version of a document, but the user can select a region by a dropdown so when the links get written out via niceurl i want to know if another version exists so:
/en/mypage/
could be
/fr/mypage/
public static string NiceURLWithLocation(int nodeId)
{
string url = umbraco.library.NiceUrl(nodeId);
if (HttpContext.Current.Session["LOCATION"] != null)
{
if (url.IndexOf("/en/") != -1)
{
string tmp = url.Replace("/en/", "/" + HttpContext.Current.Session["LOCATION"].ToString() + "/");
//this returns a page - not what i want - need to know if the node actually exists
System.Xml.XPath.XPathNodeIterator page = umbraco.library.GetXmlDocumentByUrl("http://"+HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + tmp);
if (page != null)
{
url = tmp;
}
}
}
return url;
}
Thanks in advance,
Mark
Hi Mark,
In uComponents, we have an XSLT extension that can get you the ID of a node from it's URL
Cheers, Lee.
Hi Lee,
Thanks for the fast reply! Thats exactly what i was looking.
Many thanks again,
cheers,
Mark
is working on a reply...