Copied to clipboard

Flag this post as spam?

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


  • Nick Frederiksen 18 posts 77 karma points
    Jan 24, 2011 @ 12:15
    Nick Frederiksen
    0

    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:

    1. Loop through each node from the XML.
    2. Get the URL from the XML (eg. /uk/contact.aspx).
    3. Loop throug all nodes in the umbraco.config file, which has an ID attribute.
    4. Use umbraco.library.NiceUrl() on that id, compare with passed url and return the node (or null if not found).
    5. Backup node. Saving all relevant properties.
    6. Set new values, (or create new node, if a node wasn't found by URL).
    7. 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

    umbraco 4.5.2 .NET 4.0

    Windows Server 2008 R2 (IIS7)

  • Nick Frederiksen 18 posts 77 karma points
    Jan 25, 2011 @ 14:00
    Nick Frederiksen
    0

    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.

Please Sign in or register to post replies

Write your reply to:

Draft