CakePHP分页动作

时间:2014-05-07 10:48:07

标签: pagination cakephp-2.0

你能说出为什么排序不适用于这个动作:

    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'));
}

并且查看看起来:

<th><?php echo $this->Paginator->sort('price'); ?></th>
<?php foreach ($category[0]['Product'] as $product): ?>
        <tr>
            <td><?php echo h($product['price']); ?>&nbsp;</td>         
        </tr>
    <?php endforeach; ?>

当我点击价格时,它刷新我的页面,但排序不起作用。出了点问题,我不知道为什么。

1 个答案:

答案 0 :(得分:0)

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');
}