Implement pagination for people page.
This commit is contained in:
@@ -12,9 +12,12 @@ class ViewPeople extends HTMLController
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
|
||||
$start = ($page - 1) * self::PER_PAGE;
|
||||
$total_count = Tag::getCount(1, 'Person');
|
||||
|
||||
// Fetch subalbums.
|
||||
// !!! TODO: pagination.
|
||||
$subalbums = Tag::getPeople();
|
||||
$subalbums = Tag::getPeople(0, $start, self::PER_PAGE);
|
||||
|
||||
// What assets are we using?
|
||||
$id_assets = array_map(function($album) {
|
||||
@@ -36,10 +39,18 @@ class ViewPeople extends HTMLController
|
||||
];
|
||||
}
|
||||
|
||||
$index = new AlbumIndex($albums);
|
||||
|
||||
parent::__construct('People - ' . SITE_TITLE);
|
||||
$this->page->adopt($index);
|
||||
$this->page->setCanonicalUrl(BASEURL . '/people/');
|
||||
$this->page->adopt(new AlbumIndex($albums));
|
||||
|
||||
$pagination = new PageIndex([
|
||||
'recordCount' => $total_count,
|
||||
'items_per_page' => self::PER_PAGE,
|
||||
'start' => $start,
|
||||
'base_url' => BASEURL . '/people/',
|
||||
'page_slug' => 'page/%PAGE%/',
|
||||
]);
|
||||
$this->page->adopt(new Pagination($pagination));
|
||||
|
||||
$this->page->setCanonicalUrl(BASEURL . '/people/' . ($page > 1 ? 'page/' . $page . '/' : ''));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user