Skip to content

@gabesumner /gist:1195950
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Recompile (re-evaluate) the URL associated with all Sitefinity blog posts
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();
}
}
}
}
@gabesumner
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.