mirror of
https://github.com/getgrav/grav.git
synced 2026-03-06 04:21:34 +01:00
add metod to get all pages
This commit is contained in:
@@ -331,6 +331,26 @@ class Pages
|
||||
return $blueprint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all pages
|
||||
* @return Collection
|
||||
*/
|
||||
public function all(Page $current = null)
|
||||
{
|
||||
$all = new Collection();
|
||||
$current = $current ?: $this->root();
|
||||
|
||||
if ($current->routable()) {
|
||||
$all[$current->path()] = [ 'slug' => $current->slug() ];
|
||||
}
|
||||
|
||||
foreach ($current->children() as $next) {
|
||||
$all->append($this->all($next));
|
||||
}
|
||||
|
||||
return $all;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of route/title of all pages.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user