mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
Sort order save in _Live table
This commit is contained in:
parent
b6f03225d0
commit
2eb6213c79
@ -463,6 +463,9 @@ class GridFieldOrderableRows extends RequestHandler implements
|
|||||||
if ($class == $this->getSortTable($list)) {
|
if ($class == $this->getSortTable($list)) {
|
||||||
$isVersioned = $class::has_extension('Versioned');
|
$isVersioned = $class::has_extension('Versioned');
|
||||||
}
|
}
|
||||||
|
if ($class::has_extension('Versioned')) {
|
||||||
|
$isVersioned = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Loop through each item, and update the sort values which do not
|
// Loop through each item, and update the sort values which do not
|
||||||
// match to order the objects.
|
// match to order the objects.
|
||||||
@ -505,11 +508,15 @@ class GridFieldOrderableRows extends RequestHandler implements
|
|||||||
// similar to the SiteTree where you change the position, and then
|
// similar to the SiteTree where you change the position, and then
|
||||||
// you go into the record and publish it.
|
// you go into the record and publish it.
|
||||||
foreach($sortedIDs as $sortValue => $id) {
|
foreach($sortedIDs as $sortValue => $id) {
|
||||||
if($map[$id] != $sortValue) {
|
|
||||||
$record = $class::get()->byID($id);
|
$record = $class::get()->byID($id);
|
||||||
|
if ($map[$id] != $sortValue) {
|
||||||
$record->$sortField = $sortValue;
|
$record->$sortField = $sortValue;
|
||||||
$record->write();
|
$record->write();
|
||||||
}
|
}
|
||||||
|
// Update stage to live only for published records
|
||||||
|
if ($record->isPublished()) {
|
||||||
|
$record->publish('Stage', 'Live');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user