* DOCS Add missing content from beta/rc changelogs * DOCS Add documentation for report count limiting. This was added to the report module README but really belongs here. * DOCS Add information about some new features. * DOCS Add and standardise anchor links. * DOCS Various updates to wording and formatting in 4.11.0 changelog * DOCS Move php changelog notes This is consistent with their placement in the 4.10.0 changelogs. * DOCS Requested PR changes * DOCSUse relative URLs for links to docs from changelog. * DOCS Use code blocks for terminal commands * DOCS requested PR changes * DOCS Don't need to inline recipe to downgrade graphql. * DOCS Move php parts back where they were. * DOCS Fix typos in changelog.
2.9 KiB
title | summary |
---|---|
Customise site reports | Creating your own custom data or content reports. |
Customise site reports
Introduction
Reports are a useful feature in the CMS designed to provide a view of your data or content. You can access the site reports by clicking Reports in the left hand side bar and selecting the report you wish to view.
Counts in ReportAdmin
For large datasets, the reports section may take a long time to load, since each report is getting a count of the items it contains to display next to the title.
To mitigate this issue, there is a cap on the number of items that will be counted per report. This is set at 10,000 items by default, but can be configured using the limit_count_in_overview
configuration variable. Setting this to null
will result in showing the actual count regardless of how many items there are.
SilverStripe\Reports\Report:
limit_count_in_overview: 500
[notice]
Note that some reports may have overridden the getCount
method, and for those reports this may not apply.
[/notice]
Default reports
By default the CMS ships with several basic reports:
- 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
Modules may come with their own additional reports.
Creating custom reports
Custom reports can be created quickly and easily. A general knowledge of Silverstripe CMS's datamodel and ORM is useful before creating a custom report.
Inside the app/code folder create a file called CustomSideReport.php. Inside this file we can add our site reports.
The following example will create a report to list every page on the current site.
CustomSideReport.php
use SilverStripe\Reports\Report;
class CustomSideReport_NameOfReport extends Report
{
// the name of the report
public function title()
{
return 'All Pages';
}
// what we want the report to return
public function sourceRecords($params = null)
{
return Page::get()->sort('Title');
}
// which fields on that object we want to show
public function columns()
{
$fields = [
'Title' => 'Title'
];
return $fields;
}
}
More useful reports can be created by changing the DataList
returned in the sourceRecords
function.
Notes
CustomSideReport_ReportName
must extendReport
- It is recommended to place all custom reports in the 1 file.
- Create a CustomSideReport.php file and add classes as you need them inside for each report
TODO
- How to format and make advanced reports.
- More examples