Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Archiving and moving expired content

Go to End

4 Posts   2878 Views


Community Member, 25 Posts

27 March 2008 at 9:22am

Edited: 27/03/2008 9:22am

I'm currently working an events site that needs the ability to automatically move expired events from being children of the 'Upcoming Events' page to being children of the 'Archived Events' page.

Here's the code I've come up with that nearly works (note - 7 is the ID of the Upcoming Events page, 9 of the Archives page)...

	function archiveEvents(){
		$limitSearch = 'ParentID = 7 AND eventDateStart < now() AND (eventDateEnd < now() OR eventDateEnd is NULL)';
		$objEvents = DataObject::get('Event', $limitSearch,'','');
			foreach($objEvents as $record => $items){

Now, when this function gets triggered, the ParentID of any pages in question gets updated in the SiteTree_Live table, but not the SiteTree table itself. So, everything appears as it should when viewing the site, but in the CMS itself, the archived pages are still appearing as children of the Upcoming Events page.

How do I get the SiteTree table to update in the same way the SiteTree_Live table?


Community Member, 501 Posts

28 March 2008 at 3:22am

Try to do this:

$items->publish("Stage", "Live");

instead of



Community Member, 25 Posts

28 March 2008 at 9:05am

magic. that's the trick. cheers.


Community Member, 15 Posts

25 July 2008 at 6:54pm


I am working in my first SilverStripe site and need some serious help showing events. Looking at your site for Westpac Stadium, I see that you are doing exactly what I need help with.

Could you assist me in setting that up so I may show upcoming events on my home page and an events page.

My site is :

Any help would be greatly appreciated.