public function latestPages($count = 10) { /** @var Pages $pages */ $pages = $this->grav['pages']; $latest = []; if (is_null($pages->routes())) { return null; } foreach ($pages->routes() as $url => $path) { $page = $pages->dispatch($url, true); if ($page && $page->routable()) { $latest[$page->route()] = ['modified' => $page->modified(), 'page' => $page]; } } // sort based on modified uasort($latest, function ($a, $b) { if ($a['modified'] == $b['modified']) { return 0; } return $a['modified'] > $b['modified'] ? -1 : 1; }); // build new array with just pages in it $list = []; foreach ($latest as $item) { $list[] = $item['page']; } return array_slice($list, 0, $count); }