Pagination + categorisation

Pagination must take place after your filtering:

 $items = $page->children()->listed();
// add the categories filter
  if($category = param('category')) {
    //Used for multiple words categories
    $category = urldecode(param('category'));    
    $items = $items->filterBy('cat', $category, ',');
  }

$items      = $items->paginate(12);
$pagination = $items->pagination();
$categories = $items->pluck('cat', ',', true);
1 Like