Try our conversational search powered by Generative AI!

Move Page of Episerver which is 6 months old than current date


i want to find all NewsPage within my solution and move them to a different folder if it is than 6 months old than current date

i want to create a schedule job for the same.

i have created a method which returns me all NewsPage within my solution. but i am not sure how to check each page which is less than 6 months

Below is the code for finding the NewsPage in my current solution.

public static PageDataCollection GetPagesRecursively(PageReference parent, string languageId, string subpageType)
PropertyCriteriaCollection criterias = new PropertyCriteriaCollection();
return FindPagesWithAllCriterias(parent, languageId, criterias, subpageType);

var test = VGG.Consid.Utilities.GetPagesRecursively(PageReference.StartPage, "sv", "NewsPage");

As Per the code i will get all the NewsPage in Var i want to filter the news page which is 6 months old than current date

can any 1 help me on this?

May 13, 2016 12:29
IEnumerable<NewsPage> pages = new List<NewsPage>();
var oldPages = pages.Where(p => p.Created < DateTime.Now.AddMonths(-6));

Easiest to use Linq...if you don't have extremely many pages that is...but in a scheduled job you should be fine.

Edited, May 13, 2016 13:16


It sounds like a job for the built-in Archive function. It allows you to set an expiration date (your 6 months) and where the Page should be moved when the page has expired. You can use the "SetDefaultValues" on your NewsPageType in order to apply the 6 month threshold.

You can access the Page specific settings via Tools -> Manage Expiration and Archiving. Remember to start the Scheduled Job named "Archive Function".

Casper Aagaard Rasmussen

May 14, 2016 16:56

Yup...or leave them and hide them instead from listing. Moving pages breaks incoming links and hurts seo... :)

May 14, 2016 17:32
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.