Discover unpublished records in your Silverstripe install
This module provides an extension to automatically add versioned listings to configured managed models in a ModelAdmin subclass.
At present, it provides:
This helps to solve a common question from our content editors "What remains to be published?"
Install using composer:
composer require nswdpc/silverstripe-versioned-record-discovery
If you are new to creating ModelAdmins to allow easy manipulation of data in the administration area of a Silverstripe website, the ModelAdmin documentation is a great starting point.
The report will automatically show all versioned records in the system.
If you wish to set a different default model for the reporting view, set this in configuration (using the Page
class as an example):
---
Name: 'default-target-model'
---
NSWDPC\Utilities\VersionedRecordDiscovery\UnpublishedRecordReport:
default_target_model: 'Page'
This is slightly more involved, but provides an unpublished record view directly in relevant modeladmins, without needing to fiddle with filters.
Here is an example of a ModelAdmin with three managed models in a Silverstripe website.
We want to add 'unpublished' record listings in the modeladmin for the first two versioned record types, so our content editors can easily find the unpublished records.
An unpublished record is one that exists on the draft stage but not on the live stage. It may have been previously published and unpublished.
Note that the configured record classes must have the Versioned extension for this to work.
<?php
namespace Amazing;
use SilverStripe\Admin\ModelAdmin;
class RecordModelAdmin extends ModelAdmin
{
private static $url_segment = 'records';
// Managed models for this ModelAdmin
private static $managed_models = [
VersionedRecordTypeOne::class,// we want an 'unpublished' tab for this
VersionedRecordTypeTwo::class,// and this
OtherRecord::class,
];
/**
* Add the following to your model admin configuration
* Gotcha: do not use - characters in the keys!
*/
private static $unpublished_tabs = [
'recordtypeoneslug' => VersionedRecordTypeOne::class,
'recordtypetwoslug' => VersionedRecordTypeTwo::class
];
}
Apply the extension in YAML configuration
---
Name: myrecord-versioned-tabs
---
Amazing\RecordModelAdmin:
extensions:
- 'NSWDPC\VersionedTabs\UnpublishedTabAdminExtension'
Run a dev/build
+ flush=1
and you will see two new tabs in the relevant administration screen.
When clicked, they will list unpublished records only. The default configured $managed_models
remain untouched.
Add additional maintainers here and/or include authors in composer
We welcome bug reports, pull requests and feature requests on the Github Issue tracker for this project.
Please review the code of conduct prior to opening a new issue.
If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers.
Please review the code of conduct prior to completing a pull request.
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem