2011-02-07 07:48:44 +01:00
|
|
|
# Site Reports
|
|
|
|
|
|
|
|
## Introduction
|
|
|
|
A report is a little bit of functionally in the CMS designed to provide a report of your data or content. You can access
|
2014-11-11 06:15:34 +01:00
|
|
|
the site reports by clicking *Reports* in the left hand side bar and selecting the report you wish to view.
|
2011-02-07 07:48:44 +01:00
|
|
|
|
|
|
|
![](_images/sitereport.png)
|
|
|
|
|
|
|
|
|
|
|
|
## Default Reports
|
|
|
|
|
2014-11-11 06:15:34 +01:00
|
|
|
By default the CMS ships with several basic reports:
|
2011-02-07 07:48:44 +01:00
|
|
|
|
2014-11-11 06:15:34 +01:00
|
|
|
* VirtualPages pointing to deleted pages
|
|
|
|
* RedirectorPages pointing to deleted pages
|
|
|
|
* Pages with broken files
|
|
|
|
* Pages with broken links
|
|
|
|
* Broken links report
|
|
|
|
* Pages with no content
|
|
|
|
* Pages edited in the last 2 weeks
|
2011-02-07 07:48:44 +01:00
|
|
|
|
2014-11-11 06:22:45 +01:00
|
|
|
Modules may come with their own additional reports.
|
2011-02-07 07:48:44 +01:00
|
|
|
|
2014-11-11 06:15:34 +01:00
|
|
|
## Creating Custom Reports
|
2011-02-07 07:48:44 +01:00
|
|
|
|
2014-11-11 06:15:34 +01:00
|
|
|
Custom reports can be created quickly and easily. A general knowledge of SilverStripe's
|
|
|
|
[Datamodel](/topics/datamodel) is useful before creating a custom report.
|
2011-02-07 07:48:44 +01:00
|
|
|
|
2014-11-11 06:15:34 +01:00
|
|
|
Inside the *mysite/code* folder create a file called *CustomSideReport.php*. Inside this file we can add our site reports.
|
2011-02-07 07:48:44 +01:00
|
|
|
|
2014-11-11 06:22:45 +01:00
|
|
|
The following example will create a report to list every page on the current site.
|
2011-02-07 07:48:44 +01:00
|
|
|
|
2014-11-11 06:15:34 +01:00
|
|
|
###CustomSideReport.php
|
2011-02-07 07:48:44 +01:00
|
|
|
|
|
|
|
:::php
|
2014-11-11 06:15:34 +01:00
|
|
|
class CustomSideReport_NameOfReport extends SS_Report {
|
|
|
|
|
|
|
|
// the name of the report
|
2012-01-30 23:13:42 +01:00
|
|
|
public function title() {
|
2014-11-11 06:15:34 +01:00
|
|
|
return 'All Pages';
|
2011-02-07 07:48:44 +01:00
|
|
|
}
|
|
|
|
|
2014-11-11 06:22:45 +01:00
|
|
|
// what we want the report to return
|
2014-11-11 06:15:34 +01:00
|
|
|
public function sourceRecords($params = null) {
|
|
|
|
return Page::get()->sort('Title');
|
2011-02-07 07:48:44 +01:00
|
|
|
}
|
|
|
|
|
2014-11-11 06:15:34 +01:00
|
|
|
// which fields on that object we want to show
|
|
|
|
public function columns() {
|
|
|
|
$fields = array(
|
|
|
|
'Title' => 'Title'
|
2011-02-07 07:48:44 +01:00
|
|
|
);
|
2014-11-11 06:15:34 +01:00
|
|
|
|
|
|
|
return $fields;
|
|
|
|
}
|
2011-02-07 07:48:44 +01:00
|
|
|
}
|
2014-11-11 06:15:34 +01:00
|
|
|
|
|
|
|
More useful reports can be created by changing the `DataList` returned in the `sourceRecords` function.
|
2011-02-07 07:48:44 +01:00
|
|
|
|
|
|
|
## Notes
|
|
|
|
|
2014-11-11 06:15:34 +01:00
|
|
|
* `CustomSideReport_ReportName` must extend `SS_Report`
|
|
|
|
* It is recommended to place all custom reports in the 1 file.
|
2014-11-11 06:22:45 +01:00
|
|
|
* Create a *CustomSideReport.php* file and add classes as you need them inside for each report
|
2011-02-07 07:48:44 +01:00
|
|
|
|
|
|
|
## TODO
|
|
|
|
|
2014-11-11 06:15:34 +01:00
|
|
|
* How to format and make advanced reports.
|
|
|
|
* More examples
|
2011-02-07 07:48:44 +01:00
|
|
|
|
|
|
|
## API Documentation
|
2014-11-11 06:22:45 +01:00
|
|
|
`[api:ReportAdmin]`
|