Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add page.next_siblings and page.previous_siblings #48

Merged
merged 1 commit into from

2 participants

@mavdhe

Useful when moving up the parents tree and trying to find out what the siblings of the parent are.

@kolber kolber merged commit 1517c6c into kolber:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 24, 2012
  1. @mavdhe
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 0 deletions.
  1. +4 −0 app/page-data.inc.php
View
4 app/page-data.inc.php
@@ -157,6 +157,10 @@ static function create_collections($page) {
$page->siblings = Helpers::list_files($parent_path, '/^\d+?\.(?!'.$split_url[(count($split_url) - 1)].')/', true);
# page.siblings_and_self
$page->siblings_and_self = Helpers::list_files($parent_path, '/^\d+?\./', true);
+ # page.next_siblings / page.previous_siblings
+ $index = self::get_index($page->data['siblings_and_self'], $page->file_path);
+ $page->previous_siblings = array_slice($page->data['siblings_and_self'], 0, $index, true);
+ $page->next_siblings = array_slice($page->data['siblings_and_self'], $index, count($page->data['siblings_and_self']), true);
# page.next_sibling / page.previous_sibling
$neighboring_siblings = self::extract_closest_siblings($page->data['siblings_and_self'], $page->file_path);
$page->previous_sibling = array($neighboring_siblings[0]);
Something went wrong with that request. Please try again.