Find + Pagination
Closed this issue · 3 comments
In the tutorial: https://github.com/CakeDC/tags/blob/master/Docs/Tutorials/Find-Tagged-Objects.md#pagination-usage-example
There's a "Pagination usage example". This example provides an array of 'Tagged' and 'Tag' elements. This is different than the Find example, which retrieves an array of the Model elements, i.e. 'Recipe', ready to set to the view.
It would be useful to have an example ready to copy & paste, as the Find usage examples are, which includes Pagination, so just using $this->set('recipes', $recipes);
the view would have the paginated results including the Recipe elements.
One possibility is the following code. It will retrieve all the recipes and bring them to the view, ready to show.
public function index() {
if (isset($this->passedArgs['by'])) {
$recipes = $this->Paginator->paginate('Tagged', array(
'Tagged.model' => 'Recipe',
'Tag.keyname' => $this->passedArgs['by']
));
} else {
$this->Recipe->recursive = 1;
$recipes = $this->paginate();
}
$this->set('recipes', $recipes);
}
Thanks for the feedback @rogerpro!
The example you provided is more like an different way to achieve the same result, but for me more examples are always better. 👍
Closing issue - Please re-open if necessary!