mirror of
https://github.com/getgrav/grav.git
synced 2026-07-08 10:52:33 +02:00
Fixed reordering flex pages
This commit is contained in:
@@ -255,29 +255,25 @@ class PageObject extends FlexPageObject
|
||||
/** @var PageCollection|null $siblings */
|
||||
$siblings = $siblings->getCollection()->withOrdered()->orderBy(['order' => 'ASC']);
|
||||
|
||||
// Remove old copy of the current page from the siblings list.
|
||||
$storageKey = $this->getStorageKey();
|
||||
if ($storageKey !== null) {
|
||||
$siblings->remove($storageKey);
|
||||
}
|
||||
|
||||
$filesystem = Filesystem::getInstance(false);
|
||||
$oldParentKey = ltrim($filesystem->dirname("/$storageKey"), '/');
|
||||
$newParentKey = $this->getProperty('parent_key');
|
||||
$isMoved = $oldParentKey !== $newParentKey;
|
||||
$order = !$isMoved ? $this->order() : false;
|
||||
|
||||
foreach ($siblings as $sibling) {
|
||||
$basename = basename($sibling->getKey());
|
||||
if (!in_array($basename, $ordering, true)) {
|
||||
$ordering[] = $basename;
|
||||
if ($storageKey !== null) {
|
||||
if ($order) {
|
||||
// Add current page back to the list if it's ordered.
|
||||
$siblings->set($storageKey, $this);
|
||||
} else {
|
||||
// Remove old copy of the current page from the siblings list.
|
||||
$siblings->remove($storageKey);
|
||||
}
|
||||
}
|
||||
|
||||
// Add current page back to the list if it's ordered.
|
||||
if ($order !== false) {
|
||||
$siblings->set($storageKey, $this);
|
||||
$basename = basename($this->getKey());
|
||||
foreach ($siblings as $sibling) {
|
||||
$basename = basename($sibling->getKey());
|
||||
if (!in_array($basename, $ordering, true)) {
|
||||
$ordering[] = $basename;
|
||||
}
|
||||
|
||||
@@ -152,6 +152,10 @@ trait PageTranslateTrait
|
||||
}
|
||||
}
|
||||
|
||||
if ($language === '') {
|
||||
|
||||
}
|
||||
|
||||
return $language;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user