A customer of mine wants me to build an automatic archivingh job for their news-pages. When a news-page has passed it's stop published-date they want to move that page to a specific Month-folder in the three-structure (for example: If a page has it's stop published date 2011-01-24 that page should be moved to the january-container under the 2011-container in the three structure). They know that they can asign wich archive each page should be archived to themself but they want it to be all automatic.
My first thought was to asign every pages ArchiveLink dynamicly in code behind but I noticed that the ArchiveLink-property is read-only so I had to try a different approach.
Is there a way to make the ArchiveLink-property wrtiable, or do anyone here have any other good pointers on how I should resolve this task?
Rather than assigning the property on each page, use a property on the container (I assume that news pages are in, if not a single, just a few containers). This should pont to the root of the archive. It could also be a dynamic property.
If needed you can make your property look like the standard property (but preferably only available on containers) and hide the original archive property by using the trick Anders mentions in this forum thread: http://world.episerver.com/Templates/Forum/Pages/thread.aspx?id=46551
Then of course you have to store some setting for the page type to use for the container pages, as a property on the start page/settings page, key in appSettings etc. Then create a scheduled job which finds expired pages and reads the dynamic property (or traverses the tree to find the container page's property) to get the info where to move the page. Add some logic for finding/creating the year and month containers.
You could do it the other way around
Every month create a new month page, and move pages to that month page.
automagily ofcourse :)
The PageArchiveLink doesn't appear to be read only? Have you tried using CreateWritableClone if you are trying to update a page property programmatically?
You could always hook into the Published event on the news page type and set the PageArchiveLink link based on the end publish date. It just needs to ensure that the archive/year/month structure exists before setting the link.
It becomes fully automatic and uses the standard archive function...
Alexander, at Epinova we have a custom module that does exactly what you need - archives pages into a year/month structure with a scheduled job. This module is in use in several of our production sites. It will be available shortly on epicode or codeplex, in the mean time I can send you the files you need. Email me at firstname.lastname@example.org if you're interested!
Thanks for the input! You've given me a lot of good information and pointers. I'm going to try the module that Arild spoke about.
Hey Arlid, the module you use seems pretty cool any idea on when it will be published onto EPiCode ?
Minesh - send your email address to me (email@example.com) and I'll send you the module. Haven't had time to upload to EPiCode.
For reference - the Epinova.DateTreeArchive custom archiving module I mentioned above is now available at https://www.coderesort.com/p/epicode/wiki/Epinova.DateTreeArchive