From 20e771f1213b188d87e5fa74e4b3af87debcf59f Mon Sep 17 00:00:00 2001 From: Gert Date: Mon, 20 Apr 2015 20:53:39 +0200 Subject: [PATCH] add metod to get all pages --- system/src/Grav/Common/Page/Pages.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index fd70981d6..4f52f8e6c 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -331,6 +331,26 @@ class Pages return $blueprint; } + /** + * Get all pages + * @return Collection + */ + public function all(Page $current = null) + { + $all = new Collection(); + $current = $current ?: $this->root(); + + if ($current->routable()) { + $all[$current->path()] = [ 'slug' => $current->slug() ]; + } + + foreach ($current->children() as $next) { + $all->append($this->all($next)); + } + + return $all; + } + /** * Get list of route/title of all pages. *