dev-master
9999999-devA library that automatically moves pages to a specific archive page when they expire.
MIT
The Requires
silverstripe archive
A library that automatically moves pages to a specific archive page when they expire.
This module provides a way to define dates when certain pages should be automatically archived. By archiving I mean to move a page to another location in the website and still keep it published., (*1)
The module doesn't lock you to only use some specific class or inherit from a class defined by the module. Instead, the module provides DataExtensions that you will use to decorate your own classes, be them something like Page or SiteTree. Or better yet, create new classes like ArchivablePage and ArchiveDestination that both extend Page or SiteTree. But in the end: you decide. The only limitation is that your classes must be extend SiteTree - the module won't work on any other DataObjects! (If somebody would like to remove this limitation, I would gladly review a pull request about it! :) )., (*2)
First you just need a few new SiteTree classes:, (*3)
class ArchivablePage extends Page { private static $extensions = array('AutoArchivableExtension'); } class ArchivablePage_Controller extends Page_Controller { } class ArchiveDestination extends Page { private static $extensions = array('AutoArchiveDestination'); } class ArchiveDestination_Controller extends Page_Controller { }
Let's see what we have here... ArchivablePage is a class for pages that can be moved to somewhere automatically. The reason why to have an own class for these pages is that perhaps you do not want ALL pages to have the auto archive options cluttering the CMS, you just need them for some pages. There not much more about the class. You can of course put the extension to some your already existing class and of course it's possible to define the extension in YAML too. This was just a tidy way to show the setup., (*4)
Then we need to have a place where to actually move stuff when we will finally come to that point. This is what ArchiveDestination is used for. The system is simple and flexible, but hopefully not complicated. The simplest site would use one page of this class and place it where ever needed in the page tree. The module finds it and moves the archivable pages under it when it's time to do so., (*5)
If you need multiple destinations, that can be done too. Some pages will go here and some pages there. First of all, you have an option to select to which destination page a certain archivable page will go, which is good for precise control., (*6)
But if you have a lot of archivable pages, you don't want to define the destinations manually for every one of them. In this case, you can leave the destination option to it's default value, auto mode. Auto mode will take a look at the archivable page's siblings and see if one of them is a destination page. If is, it will be moved there. If not, it will look at the archivable page's parent's siblings, grand parent's siblings etc. If it finds nothing when traversing up the page tree, it will finally try to find a destination page regardless of it's position. If it finds multiple, it will use the first one. Simple. Perhaps not perfect for all cases, but if you have ideas, please share! :), (*7)
And finally there are cases when an archivable page cannot be moved: - No destination page was found - A destination page was found, but the page does not accept the archivable page to be it's new child., (*8)
The current status of this module is that it's still in development. I think that the features are in place and there's nothing on my mind right now that would need to be added to this module. But the features may be buggy, as the module is not very well tested. If testing goes well, I can easily rise the version number to 1.0.0 and release a stable version., (*9)
The module is not automatically automatic, you will first need to do something manually. For example, put this to your crontab:, (*10)
0 0 * * * php framework/cli-script.php dev/tasks/AutoArchiveTask
This will make your server to perform the archiving every midnight., (*11)
Or to test it manually, just visit: www.yoursite.com/dev/tasks/AutoArchiveTask, (*12)
Name: Jarkko Linnanvirta Company: IT-Palvelu Taitava Contact: posti taitavasti fi (replace spaces with an at and a dot) Webpage: http://taitavasti.fi (Too bad, only in Finnish :D) Licence: MIT Perhaps available for small freelance projects using SilverStripe :), (*13)
Please feel free to contact if you have questions., (*14)
A library that automatically moves pages to a specific archive page when they expire.
MIT
silverstripe archive