Thursday, December 6, 2007

Umbraco + Bulk Adding New Pages

Recently I have been working on a new website for a Kennel Club organisation.

Our choice of CMS was Umbraco, i had personally never used Umbraco, but a few hours into the install and everything was going pretty well.

After doing some searches on the Umbraco forums and Google i didn't seem to find any facility to bulk load pages. Its quite possible one already exists and I just haven't found it. Anyway I thought this might be a good idea so I could gain a better understanding of how the Umbraco structure works. By trade I am very junior programmer, have little knowledge of XML and no previous experience with C#. So there's the disclaimer continue on at your own risk.

Click here to download the files you are going to need.
  • Bukimport.aspx needs to be saved into your umbraco directory (the same one that has create.aspx in it)
  • Bulkimport.dll needs to be saved to the BIN folder.
  • Book1.xls is a example of excel file of your new pages

What the Bulk Import will do:

  • It will create new nodes for the pages you specify
  • It can publish your new documents (can be turned off)
  • You can choose which node the pages will be created into
  • You can choose the document type

What the Bulk Import won't do (yet)

  • It will not assign any macro properties to the new document (eg Hide from nav)
  • It will not add any content to the new document (its all about creating structure at the moment)
  • It will not restrict your document types (eg if you have a master document type which doesn't allow children nodes then you will still be able to add child pages)

Right given that some interest is shown then if you want these above options implemented please let me know. The content for my Dog Breed pages have not yet been constructed so I have no need to bulk import content.

The screens are very ugly and confusing at the moment but that's not that point at the moment i just need some people to test this!

Obviously at the top of the page is import which you can import a new excel file its put into the same directory as bulkImport.xls hopefully you have rights I probably should change this to usercontrols or something anyhow that's where it is for now.

Controls on the page

Parent node is obviously the parent node of the new page you are going to create, you can also select any node which is higher on the grid (because it will be inserted first and we will therefore then know the Node ID)

The dropdownlist below the Grid allows you to change the parent Nodes for all pages in the grid.

Import obviously imports the new pages. May take some time depending on how many nodes you create. I imported 200 took about 30second from memory. You will be able to tell its done when the new nodes ID's are shown

Good luck and feedback would be good.



Heather Floyd, Floyd Innovations LLC said...

I have been looking for an easy way to get a lot of pages into umbraco quickly. This looks like a good start. I will try it out. What would really be useful would be the ability to include in the XLS data for each of the properties for the doctype, so you could essentially transform a table of data into a bunch of pages with content. Perhaps it wouldn't be too difficult as long as the column headers matched the property aliases...

Heather Floyd, Floyd Innovations LLC said...

After trying out your Bulk Import code, I'd like to say that it worked flawlessly as designed. I'd suggest that you include a second "Change All" option to set all the same DocType (like the ParentNode option).

You might want to look into turning this into an ascx because then it could be integrated into the umbraco backend dashboard.

Some info:'s-new-in-v3/enhancement-dashboard-now-supports-tabs

From :
To add an item to the dashboard you need to ammend/update the dashboard.xml in the Config folder.

Heres an example of the dashboard.xml but I dont know all the sections, I presume its the same as the sections in the bottom left corner of the Umbraco tools.

<?xml version="1.0" encoding="utf-8" ?>
<entry section="default">/usercontrols/LatestEdits.ascx</entry>
<entry section="content">/usercontrols/LatestEdits.ascx</entry>

Heather Floyd, Floyd Innovations LLC said...

Hmm... On my second upload, I was getting an error:

[OleDbException (0x80004005): 'SHEET1$' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +267

Which was only cleared up when I deleted the previously uploaded XLS from the /umbraco/ directory. Ideally the code would delete that file itself after the import.