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.

Archive

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

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

Creating new Site Reports


Reply

3 Posts   1343 Views

Avatar
cerelac

17 June 2008 at 4:54am (Last edited: 17 June 2008 4:54am), Community Member, 34 Posts

Hi everyone.
I've read the tutorial about creating new site reports [URL=http://doc.silverstripe.com/doku.php?id=site-reports]here[/URL] and I've created the "All Pages" site report example.
I want to know is if it's possible to create custom site reports like "Pages edited in the last 2 weeks" but, instead of 2 weeks, I would like to have something like "Pages edited in the last 3 weeks" or "Pages edited in the last month".
Best regards.

Avatar
Willr

17 June 2008 at 10:47am Forum Moderator, 5511 Posts

You can just copy the Pages edited in the last 2 weeks reports code and change the date or something. Assuming you have read the Tutorial and understand how to write your own report class etc your records() method would be

// get latest 3 weeks (21 days) of edits
function records() {
return DataObject::get("SiteTree", "`SiteTree`.LastEdited > NOW() - INTERVAL 21 DAY", "`SiteTree`.`LastEdited` DESC");
   }

Avatar
cerelac

21 June 2008 at 2:58am Community Member, 34 Posts

Thanks willr.