I am currently building an import function, inside the backoffice, for a client, where he can import texts from a XML file (generated from an old, non-umbraco CMS solution), into umbraco.
The problem starts here:
I am trying to locate nodes already present in umbraco, based on their URL, to make a backup.
The way i am trying to do that, is:
Loop through each node from the XML.
Get the URL from the XML (eg. /uk/contact.aspx).
Loop throug all nodes in the umbraco.config file, which has an ID attribute.
Use umbraco.library.NiceUrl() on that id, compare with passed url and return the node (or null if not found).
Backup node. Saving all relevant properties.
Set new values, (or create new node, if a node wasn't found by URL).
Save and publish node.
The problem lies in step 4. NiceUrl() returns only "#" (without quotation marks), even though the nodes are published, and accessible via a browser.
My questions here are:
Is there an easier way to get a node from an URL, and why does NiceUrl return #?
I have tried using NiceUrlFullPath, but it throws a NullReferenceException.
My node tree looks like this:
LanguageChooser
DA
---subpage
---subpage2
------ subsubpage
---subpage3
UK
---subpage
---subpage2
------ subsubpage
---subpage3
The odd thing is, that the only node, from which i can get an URL from, is LanguageChooser.
System info:
umbracoHideTopLevelNodeFromPath = false
Both DA and UK-nodes, has a domain attached to define languages. Urls are like: mydomain.tld/dk/subpage.aspx
It seems, that when I call the NiceUrl method, in a different thread than the page, it will fail. So my solution was, to move the backup code, outside the thread, get all nodes, loop through each node, get the NiceUrl, and store the URL and the Document, in a dictionary. I then use the dictionary to find the nodes.
umbraco.library.NiceUrl() returns #
Hi,
I am currently building an import function, inside the backoffice, for a client, where he can import texts from a XML file (generated from an old, non-umbraco CMS solution), into umbraco.
The problem starts here:
I am trying to locate nodes already present in umbraco, based on their URL, to make a backup.
The way i am trying to do that, is:
The problem lies in step 4. NiceUrl() returns only "#" (without quotation marks), even though the nodes are published, and accessible via a browser.
My questions here are:
Is there an easier way to get a node from an URL, and why does NiceUrl return #?
I have tried using NiceUrlFullPath, but it throws a NullReferenceException.
My node tree looks like this:
LanguageChooser
DA
---subpage
---subpage2
------ subsubpage
---subpage3
UK
---subpage
---subpage2
------ subsubpage
---subpage3
The odd thing is, that the only node, from which i can get an URL from, is LanguageChooser.
System info:
umbracoHideTopLevelNodeFromPath = false
Both DA and UK-nodes, has a domain attached to define languages. Urls are like: mydomain.tld/dk/subpage.aspx
umbraco 4.5.2 .NET 4.0
Windows Server 2008 R2 (IIS7)
Hi,
Kinda solved it my self.
It seems, that when I call the NiceUrl method, in a different thread than the page, it will fail. So my solution was, to move the backup code, outside the thread, get all nodes, loop through each node, get the NiceUrl, and store the URL and the Document, in a dictionary. I then use the dictionary to find the nodes.
is working on a reply...