Skip to content

Commit

Permalink
Fix resource versions pagination issue
Browse files Browse the repository at this point in the history
  • Loading branch information
samerton committed Oct 10, 2021
1 parent 06b5a6b commit edac84c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions upload/modules/Resources/pages/resources/resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit edac84c

Please sign in to comment.