Move Blog
Hey guys - i am trying to move blogs posts from one blog to the other - i don't seem to see the option for that
how can this be done - i cannot go and rewrite all the blog posts in a different blog.....
Thanks!
you can do this with the BlogsManager API. Create a new page like CopyBlogPosts.aspx and put something like this in the code behind:
protected
void
Page_Load(
object
sender, EventArgs e)
// retrieve manager
var blogMgr = BlogsManager.GetManager();
// retreive blogs
var oldBlog = blogMgr.GetBlogs().SingleOrDefault(b => b.Title ==
"Test Blog 1"
);
var newBlog = blogMgr.GetBlogs().SingleOrDefault(b => b.Title ==
"Test Blog 2"
);
// parse through old posts, only get published ones (avoids duplicates)
foreach
(var oldBlogPost
in
oldBlog.BlogPosts.Where(p => p.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live))
// create new post
var newBlogPost = blogMgr.CreateBlogPost();
// copy properties
newBlogPost.Parent = newBlog;
newBlogPost.Title = oldBlogPost.Title;
newBlogPost.UrlName = oldBlogPost.UrlName;
// ...
blogMgr.Publish(newBlogPost);
// add post to new blog
blogMgr.SaveChanges();
info was useful