Monday 9 July 2012

Bulk-moving Umbraco documents and updating their URLs

When moving an Umbraco document to a new parent, I had a problem where the 'link to document' property wouldn't update to reflect the new location.

Another problem I had was when I had to bulk move multiple nodes in one transaction.

After you've moved a document to a new parent, publishing the document isn't enough; you have to regenerate the XML from the parent down.

However, doing this every time using library.RefreshContent(); involves clearing the umbraco.config. Doing this whilst bulk-processing lots of documents means that the umbraco.config goes missing during transactions, and it will throw an exception.

To prevent this from happening, I introduced a config value to control whether that refresh takes place or not.

You can see what I've done here: You can read more about how to publish a document (including the answer I found) on the Umbraco wiki. When we've published the node and it's moved, the document's URL won't have updated. This is because the umbraco.config hasn't been updated from the database, so to get this to forcibly update, you have to:
  1. Stop the website application pool
  2. Delete the /app_data/umbraco.config file
  3. Start the application pool
When this is done, your document URLs should be updated.

Let me know if any of this isn't clear, and I'll do my best to clarify!

No comments: