Why Clydesdale?
Expertise
Strategic Partners
Blog
Contact
Home
Clydesdale Software Logo

Clydesdale Software, Inc.

355 South Teller St.

Suite 200

Lakewood, CO 80226

info@ClydesdaleSoftware.com


Follow Us: Twitter RSS



Go Back

Import Your Old Blog to a Sitefinity Blog

So you want to move your blog into Sitefinity, first you need to get your old blog data into a usable format.  If by chance your old blog data was exported to the movable type format here is something that can be of help.

 

After using the movable type parser you can now import data into the blog.  Next step is create a page that resides under the sitefinity/admin directory, call it something like BlogImporter.aspx.

 

In the newly created page in the Page_Load method handle the blog import.  Yes this is not fancy or very reusable or dynamic but how many times are you going to import a blog?

 

   15 protected void Page_Load(object sender, EventArgs e)

   16 {

   17     var fileContents = File.ReadAllText(@"C:\OldBlogDump\OldBlogExport.txt");

   18 

   19     var oldPosts = MovableTypeParser.ParseMovableTypeContent(fileContents);

   20 

   21     // create new instance of BlogManager

   22     var blogManager = new BlogManager();

   23     // get all blogs

   24     var listOfAllBlogs = blogManager.GetBlogs();

   25     if (listOfAllBlogs.Count > 0)

   26     {

   27         // get the first blog item

   28         var firstBlog = blogManager.GetBlog(((IBlog)listOfAllBlogs[0]).ID);

   29 

   30         foreach (OldPost oldPost in oldPosts)

   31         {

   32             // create a blog post by calling the CreateContent method of the

   33             // ContentManager class through the BlogManager class

   34             var postContent = blogManager.Content.CreateContent("text/html");

   35 

   36             // set the parent of the post item to be firstBlog

   37             postContent.ParentID = firstBlog.ID;

   38 

   39             // save the Content property value and the Title meta key

   40             postContent.Content = oldPost.Body;

   41             postContent.SetMetaData("Title", oldPost.Title);

   42             postContent.SetMetaData("Publication_Date", oldPost.Date);

   43             //save the Content item through the BlogManager

   44             blogManager.Content.SaveContent(postContent);

   45         }

   46     }

   47 

   48     Response.Write("Import Finished!");

   49 }

 

The import turned out to be pretty simple once I found everything I needed in documentation and other sources around the internet.

Facebook Twitter DZone It! Digg It! StumbleUpon Technorati Del.icio.us NewsVine Reddit Blinklist Add diigo bookmark