Jump to content


Category Header Sorting Links

To test this easily, you should set up a category that defaults to sorting by File Title, Ascending.

The sort_order key in the URL's for the links in the header of the categories is not working. For example, clicking Most Recent should sort by File Updated, Descending. This is because we're passing "sort_order" lowercase, which does not match this check here (Line 269 - /modules_public/display/category.php):

$sort_by = ( $this->request['sort_order'] && in_array( $this->request['sort_order'], $this->sort_by ) ) ? $this->request['sort_order'] : ( $category['coptions']['opt_sortby'] ? $this->sort_by[$category['coptions']['opt_sortby']] : 'DESC' );

$this->sort_by has two values in it, ASC and DESC. When we use the header links we're effectively setting $this->request['sort_order'] = 'desc'; which doesn't match when in_array() is run (case-sensitive check), thus the actual sorting order falls back to the category default (in this case, ascending, which isn't what we want).

Two ways to fix it... one we can alter the templates so the links pass full uppercase DESC, or (if we want to avoid template changes between maintenance releases) we can add this line above the check mentioned:

$this->request['sort_order'] = strtoupper( $this->request['sort_order'] );

Status: Fixed
Version: 2.5.1
Fixed In: 2.5.2


Updating Fixed In to: 2.5.2
Updating Status to: Fixed