improve children on pages

This commit is contained in:
floppy0 2018-02-08 16:53:35 +01:00
parent 55d304429d
commit 5a438ec442
2 changed files with 18 additions and 6 deletions

View File

@ -59,7 +59,7 @@ function buildPage($key) {
$page->setField('categoryMap', $dbCategories->getMap($categoryKey)); $page->setField('categoryMap', $dbCategories->getMap($categoryKey));
// Get the keys of the child // Get the keys of the child
$page->setField('children', $dbPages->getChildren($key)); $page->setField('childrenKeys', $dbPages->getChildren($key));
return $page; return $page;
} }

View File

@ -459,16 +459,29 @@ class Page {
return $this->parentKey()!==false; return $this->parentKey()!==false;
} }
// Returns an array with all children's key // Returns an array with all children as page-object
public function children() public function children()
{ {
return $this->getValue('children'); $list = array();
$childrenKeys = $this->getValue('childrenKeys');
foreach ($childrenKeys as $childKey) {
$child = buildPage($childKey);
array_push($list, $child);
}
return $list;
}
// Returns an array with all children's keys
public function childrenKeys()
{
return $this->getValue('childrenKeys');
} }
// Returns an array with all children's key // Returns an array with all children's key
public function subpages() public function subpagesKeys()
{ {
return $this->children(); return $this->childrenKeys();
} }
// Returns TRUE if the page has children // Returns TRUE if the page has children
@ -521,6 +534,5 @@ class Page {
} }
return $string ? implode(', ', $string) . ' ago' : 'Just now'; return $string ? implode(', ', $string) . ' ago' : 'Just now';
} }
} }