public function view($id = null)
{
if (!$this->Product->exists($id)) {
throw new NotFoundException(__('Invalid product'));
}
$this->Paginator->settings = array(
'conditions' => array(
'Product.' . $this->Product->primaryKey => $id)
);
$this->set('product', $this->paginate('Product');
}
CakePHP paginate action
-
17-07-2023 - |
Question
Can you also tell why sorting don't work with this action:
public function admin_view($id = null)
{
if (!$this->Category->exists($id)) {
throw new NotFoundException(__('Invalid product'));
}
$this->Paginator->settings = array(
'conditions' => array(
'Category.' . $this->Category->primaryKey => $id),
'limit' => $this->limit
);
$this->set('category', $this->paginate('Category'));
}
and view looks this:
<th><?php echo $this->Paginator->sort('price'); ?></th>
<?php foreach ($category[0]['Product'] as $product): ?>
<tr>
<td><?php echo h($product['price']); ?> </td>
</tr>
<?php endforeach; ?>
When I click on price it refresh my page, but sorting not working. Something wrong, I don't know why.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow