From b7bea6d6a092e2a22cf2c46fae6d04e6eace675a Mon Sep 17 00:00:00 2001 From: Tim Stallmann Date: Mon, 15 Mar 2021 10:49:35 -0400 Subject: [PATCH] Issue #936: Add pagination to collections->showAction for themes that use it --- .../controllers/CollectionsController.php | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/application/controllers/CollectionsController.php b/application/controllers/CollectionsController.php index 6900cc9af4..d71cf2f9a5 100644 --- a/application/controllers/CollectionsController.php +++ b/application/controllers/CollectionsController.php @@ -23,13 +23,31 @@ public function init() } /** - * The show collection action + * The show collection action. + * + * Note -- this also includes aspects of a browseAction in that in showing + * a single collection the action is also browsing items within that collection. */ public function showAction() { parent::showAction(); - $this->view->items = $this->_helper->db->getTable('Item')->findBy( - array('collection' => $this->view->collection->id), $this->_getBrowseRecordsPerPage()); + $recordsPerPage = $this->_getBrowseRecordsPerPage(); + $currentPage = $this->getParam('page', 1); + $params = array('collection' => $this->view->collection->id); + $records = $this->_helper->db->getTable('Item')->findBy( + $params, $recordsPerPage, $currentPage); + $totalRecords = $this->_helper->db->getTable('Item')->count($params); + + // Add pagination data to the registry. Used by pagination_links(). + if ($recordsPerPage) { + Zend_Registry::set('pagination', array( + 'page' => $currentPage, + 'per_page' => $recordsPerPage, + 'total_results' => $totalRecords, + )); + + $this->view->assign(array('items' => $records, 'total_results' => $totalRecords)); + } } /**