This module extends GridField to add some styles and labels for showing the published state of versioned objects.
Nathan Cox ([email protected])
- SilverStripe 3.1+
With composer:
composer require nathancox/versionedgridrows
Configuration via config.yml
:
VersionedGridRows:
mode: 'component' # can be "component", "config" or "always"
show_published: false # set to true to show a flag on published items as well
Options for the mode setting:
mode: 'component'
Only add row styles to GridFields with the VersionGridRows component added to them. This is done like any other component:
$gridFieldConfig->addComponent(new VersionedGridRows('Title'));
The constructor argument ("Title") specifies the name of the column the "draft" or "modified" flags will be appended to. Leave blank to not automatically append the flags.
mode: 'always'
Styles will be added to all GridFields that managed versioned objects. If you want to add flags you need to do it manually with something like this:
$summary_fields = array(
'VersionedTitle' => 'Title'
);
...
public function VersionedTitle()
{
return VersionedGridRows::get_column_content($this, $this->Title);
}
mode: 'config'
Specify a list of classes that styles will be added to.
VersionedGridRow:
mode: 'config'
classes:
- Page
- StaffMember
- HomepageSlide
You will have to add version status flags manually as shown above.