From edac84c1deb165a4cac57dc2752e8277a0ed9215 Mon Sep 17 00:00:00 2001 From: samerton Date: Sun, 10 Oct 2021 13:54:33 +0100 Subject: [PATCH] Fix resource versions pagination issue --- upload/modules/Resources/pages/resources/resource.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/upload/modules/Resources/pages/resources/resource.php b/upload/modules/Resources/pages/resources/resource.php index f613597..ea3f5b2 100644 --- a/upload/modules/Resources/pages/resources/resource.php +++ b/upload/modules/Resources/pages/resources/resource.php @@ -754,23 +754,26 @@ } else if(isset($_GET['versions'])){ // Display list of all versions - $releases = $queries->orderWhere('resources_releases', 'resource_id = ' . $resource->id, 'created', 'DESC'); + $releases = DB::getInstance()->query('SELECT * FROM nl2_resources_releases WHERE resource_id = ? ORDER BY `created` DESC', array($resource->id)); + $release_count = $releases->count(); - if(!count($releases)){ + if (!$release_count) { Redirect::to('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name)); die(); } + $releases = $releases->results(); + // Pagination $paginator = new Paginator((isset($template_pagination) ? $template_pagination : array())); - $results = $paginator->getLimited($releases, 10, $p, count($releases)); + $results = $paginator->getLimited($releases, 10, $p, $release_count); $pagination = $paginator->generate(7, URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'versions=all&')); $smarty->assign('PAGINATION', $pagination); // Assign releases to new array for Smarty $releases_array = array(); - foreach($releases as $release){ + foreach($results->data as $release){ $releases_array[] = array( 'id' => $release->id, 'url' => URL::build('/resources/resource/' . $resource->id . '-' . Util::stringToURL($resource->name) . '/', 'releases=' . $release->id),