From 8532c2d06e598ae12ba7b175b7eb7c309db7bc0f Mon Sep 17 00:00:00 2001 From: Mike Mellor Date: Tue, 5 Sep 2017 20:57:32 +0100 Subject: [PATCH] Added current position to page object (#1632) --- system/src/Grav/Common/Page/Page.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 1915f0ec7..d3e25a262 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -2269,6 +2269,23 @@ class Page return false; } + + /** + * Returns the item in the current position. + * + * @param string $path the path the item + * + * @return Integer the index of the current page. + */ + public function currentPosition() + { + $collection = $this->parent()->collection('content', false); + if ($collection instanceof Collection) { + return $collection->currentPosition($this->path()); + } + + return true; + } /** * Returns whether or not this page is the currently active page requested via the URL.