Anders G. Nordby

Lead Software Engineer at Sopra Steria

Complex import/export with EPiServer

The import/export functionality in EPiServer is great. Often, exporting content from the source site and importing it just as it is to the target site is exactly what you need. Simple and easy! If the exported pagetypes do not exist in the target site, you’re able to bring these along as well. Great – most of the time… But sometimes you have special needs.

What if the two sites are very different, and both the source site and the target site have a pagetype called Article? You wouldn’t like to clutter up the target site with a bunch of extra properties from the imported pages, would you? And maybe you’d even like to be able to distinguish the imported pages from the other pages in the target site later on? Also, what if the pagetype you wish to export contains a whole lot of properties, but you’re only interested in getting a few properties like Heading, MainIntro and MainBody?

At first it seemed that I’d not be able to do this, or at least not without a lot of coding. Nothing wrong with coding, of course, but it’s often better to look for built-in possibilities first.

Here’s how I solved this:

  1. Copy pagetype Article to ImportedArticle
    This is a functionality I almost never use (especially not after PageTypeBuilder came along), I seldom touch pagetypes in the “manual” old-fashioned way at all… But boy was I glad this functionality exists! I could obviously have made a totally new pagetype from admin mode, but in this case there were quite a few properties I wanted to include, and this seemed a faster way to get what I wanted.
  2. “Rinse”
    1. Deleted all properties of ImportedArticle not needed in the target site.
    2. Changed properties implemented with custom properties on the source side to PropertyLongString, thus eliminating the need for implementing the same custom properties on the target site.
    3. Properties on tabs only existing in the source site were moved to the Information tab.
  3. Copy pages to export to a new node
    In the source site EPiServer tree, I created a new node called ForExport. Then I copied the articles I wanted to export there.
  4. Convert Pages
    Finally I was ready for the main thing: I converted all the pages under ForExport from Article to ImportedArticle. Because all the properties in the two pagetypes had the same names, EPiServer defaulted to copying the properties I wanted and discarding the rest. Perfect!
  5. Export/import
    With all the pages under ForExport converted to ImportedArticle, I could now use the normal export/import functionality to move these pages to the target site (I included the pagetype in the export).
  6. Clean-up
    Deleting the ForExport node and everything below it, leaving the target site as it was before I started (except for the new pagetype I have introduced).

Thanks to the EPiServer World community for great help on this issue:


4 responses to “Complex import/export with EPiServer

  1. Rupali 2013-11-18 at 11:01

    How can I import/export properties with custom settings?

  2. Anders G. Nordby 2013-11-19 at 09:10

    Even if you have custom settings, the properties will actually be stored as one of the basic property types, e.g. string (this depends on how you have implemented your custom property, I often inherit from PropertyString when I create a custom property). If you’re unsure how your property is stored, you could search the tblProperties table in the EPiServer database for it, to see an example of it. If it is stored as a string, all you need to import it is a string field; if it is stored as e.g. an int, you’ll need an int field, etc.

  3. Pingback: EPiServer content migration | Patrick van Kleef Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: