我将文档跟踪到create a custom report但仍未能在CMS中生成报告。有没有其他人有这个问题?我注意到,对于旧版本,配置必须包含报告,但我在3.1中看不到这一点。
以下是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"))
);
}
}
我完成了通常的dev/build
和flush
,但仍然没有出现。
答案 0 :(得分:2)
文档现已更新,以正确显示如何制作custom site reports。
在SilverStripe 3.1中,该类应该扩展SS_Report
而不是SideReport
。
试试这个:
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;
}
}
另请注意,records()
已更改为sourceRecords($params = null)
且fieldsToShow()
已更改为columns()
。