Created
September 5, 2011 21:23
-
-
Save gabesumner/1195950 to your computer and use it in GitHub Desktop.
Recompile (re-evaluate) the URL associated with all Sitefinity blog posts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using Telerik.Sitefinity; | |
using Telerik.Sitefinity.Modules.Blogs; | |
using Telerik.Sitefinity.Blogs.Model; | |
namespace SitefinityWebApp.Extensions | |
{ | |
public partial class test : System.Web.UI.Page | |
{ | |
protected void Page_Load(object sender, EventArgs e) | |
{ | |
var manager = BlogsManager.GetManager(); | |
foreach (var post in App.WorkWith().BlogPosts().Get().ToList()) | |
{ | |
Response.Write(post.Title + "<br />"); | |
var editPost = manager.GetBlogPost(post.Id); | |
manager.RecompileItemUrls<BlogPost>(editPost); | |
manager.Lifecycle.Publish(manager.Lifecycle.GetMaster(editPost)); | |
manager.SaveChanges(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I changed the UrlFormat property associated with my Sitefinity blog posts to change the URL generated for each post. Once this property is updated, the old blog posts continue to use the old URL until manually re-saved. I didn't want to manually click through and re-save each blog post, so I used the code above to automatically recompile the URL associated with each blog post.