2
votes

I followed the docs to create a custom report but keep failing to generate the report in the CMS. Has anyone else had this problem? I noticed that with older versions, the config had to include the report, but I see no sign of this in 3.1.

Here is the contents of CustomSideReport.php

class CustomSideReport_Day extends SideReport {
    public function title() {
        return "Event Calendar";
    }

    public function records() {
        return Page::get()->sort("Title");
    }

    public function fieldsToShow() {
        return array(
            "Title" => array("NestedTitle", array("2"))
        );
    }
}

I have the done the usual dev/build and flush, but still nothing appears.

1

1 Answers

2
votes

The documentation has now been updated to correctly show how to make custom site reports.

In SilverStripe 3.1 the class should extend SS_Report instead of SideReport.

Try this:

class CustomSideReport_Day extends SS_Report {
    public function title() {
        return 'Event Calendar';
    }

    public function sourceRecords($params = null) {
        return Page::get()->sort('Title');
    }

    public function columns() {
        $fields = array(
            'Title' => 'Title'
        );

        return $fields;
    }
}

Also note that records() has changed to sourceRecords($params = null) and fieldsToShow() has changed to columns().