If you would like to Republish pages in Sitefinity 4.X for any reason this post will help you write a custom page to do this task.
Up until 4.1 this Republish page is a very important page to have as when you make changes to the template, the content pages did not get the latest changes from the template. You had to open up each and every content page and then hit Publish on that page. This is a cumbersome task especially if you have a lot of content pages.
To ease up this procedure here is a quick asp.net page to Republish all pages(and clear the cache) -
Create a page called RepublishPages.aspx on the root of the Sitefinity website. In the code behind of that page copy & paste the following code -
| 1 | using System; |
| 2 | using System.Linq; |
| 3 | using Telerik.Sitefinity; |
| 4 | using Telerik.Sitefinity.GenericContent.Model; |
| 5 | using Telerik.Sitefinity.Modules.Pages; |
| 6 | using Telerik.Sitefinity.Pages.Model; |
| 7 | |
| 8 | namespace SitefinityWebApp |
| 9 | { |
| 10 | public partial class RePublishPages : System.Web.UI.Page |
| 11 | { |
| 12 | protected void Page_Load(object sender, EventArgs e) |
| 13 | { |
| 14 | var pageNodes = App.WorkWith() |
| 15 | .Pages() |
| 16 | .LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend) |
| 17 | .Get() |
| 18 | .Where(pN => pN.Page.Status == ContentLifecycleStatus.Live) |
| 19 | .ToList(); |
| 20 | foreach (PageNode p in pageNodes) |
| 21 | { |
| 22 | var myId = p.Page.Id; |
| 23 | var manager = PageManager.GetManager(); |
| 24 | var myDraft = manager.EditPage(myId, true); |
| 25 | manager.PublishPageDraft(myDraft, true); |
| 26 | manager.SaveChanges(); |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | } |
And whenever you want to Republish pages just browse to this page and all the pages would be published with the latest changes.
NOTE: Majority of the code is from this discussion - Not answered Adding content to template does not show on pages but changed a little according to my comment here .
If you would like to download the Republish Page on the whole (aspx and codebehind) Click Here
Hope this helps
Cheers
Venkata