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.
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
Yup...or leave them and hide them instead from listing. Moving pages breaks incoming links and hurts seo... :)
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 Test...now i want to filter the news page which is 6 months old than current date
can any 1 help me on this?