Cakephp pagination sort descending

By default, when you click on a sorted pagination field, it will sort in ascending order first, is there a way to lower it first?

<th><?php echo $this->Paginator->sort('Views', 'views'); ?></th>

I want my users to see the most viewed first after clicking on a view that is no less visible.

+5
source share
1 answer

To change the default sort direction, change the code above:

<th><?php echo $this->Paginator->sort('Views', 'views, array('direction' => 'desc')); ?></th>

Once activated, the sort direction will switch between descending and ascending, as usual.

+6
source

All Articles