From 2a308d2a08e8c8fdce7d1b660a14fe3822ae602b Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 3 Dec 2014 18:13:52 -0700 Subject: [PATCH] Fixed a broken getSibling() function on the page --- system/src/Grav/Common/Page/Page.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index ffa64c619..8e95b31f8 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1245,14 +1245,16 @@ class Page { /** @var Pages $pages */ $pages = self::$grav['pages']; - $parent = $pages->get($this->parent); - $current = $this->slug(); + $parent = $this->parent(); + $children = $parent->children(); - $keys = array_flip(array_keys($parent->items)); - $values = array_values($parent->items); - $index = $keys[$current] - $direction; + $adjacent = $children->adjacentSibling($this->path(), $direction); - return array_key_exists($index, $values) ? $pages->get($values[$index]) : $this; + if (!$adjacent) { + return null; + } + + return $adjacent; } /**