From 077ba28706f38ea00804f4c39644e34e40ff0b71 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 19 Oct 2015 15:12:21 -0600 Subject: [PATCH] Added support for collections with `@root` page and recurse flag --- system/src/Grav/Common/Page/Page.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 773360ff9..2deeaf6f9 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1962,6 +1962,10 @@ class Page if (!empty($parts)) { switch ($parts[0]) { case 'modular': + if (!empty($params) && $params[0] === false) { + $results = $this->children()->nonModular()->published(); + break; + } $results = $this->children()->modular()->published(); break; case 'children': @@ -1973,10 +1977,24 @@ class Page case '@page': if (!empty($params)) { - $page = $this->find($params[0]); - if ($page) { - $results = $page->children()->nonModular()->published(); + /** @var Pages $pages */ + $pages = self::getGrav()['pages']; + + list($what, $recurse) = array_pad($params, 2, null); + + if ($what == '@root') { + $page = $pages->root(); + } else { + $page = $this->find($what); } + + if ($page) { + if ($recurse) { + $results = $pages->all($page)->nonModular()->published(); + } else { + $results = $page->children()->nonModular()->published(); + } + } } break;