From a9df8965382c642731bcd98e04d622bf2a47c77a Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Mon, 9 Mar 2020 10:17:11 +0200 Subject: [PATCH] Flex Pages: added has-children to getLevelListing() response --- system/src/Grav/Common/Flex/Types/Pages/PageIndex.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php index 742de7227..2d7ea4b59 100644 --- a/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php +++ b/system/src/Grav/Common/Flex/Types/Pages/PageIndex.php @@ -360,7 +360,8 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface 'type' => 'root', 'modified' => $page->modified(), 'size' => 0, - 'symlink' => false + 'symlink' => false, + 'has-children' => false ]; } else { $response[] = [ @@ -399,6 +400,7 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface $selected = $child->path() === $extra; $includeChildren = \is_array($leaf) && !empty($leaf) && $selected; if ($field) { + $child_count = count($child->children()); $payload = [ 'name' => $child->title(), 'value' => $child->rawRoute(), @@ -407,8 +409,9 @@ class PageIndex extends FlexPageIndex implements PageCollectionInterface 'extension' => $child->extension(), 'type' => 'dir', 'modified' => $child->modified(), - 'size' => count($child->children()), - 'symlink' => false + 'size' => $child_count, + 'symlink' => false, + 'has-children' => $child_count > 0 ]; } else { // TODO: all these features are independent from each other, we cannot just have one icon/color to catch all.