如何传递分页参数与附加params cakephp? [英] How to pass pagination parameters with additional params cakephp?

查看:165
本文介绍了如何传递分页参数与附加params cakephp?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类别列表,显示其下的项目列表。



因此:



路由具有:

  Router :: connect('/ category /:slug',array('controller'=& ',
'action'=>'catview','slug'=>'[0-9a-zA-Z] +'));
Router :: connect('/ category /:slug /:page',array('controller'=>'Product',
'action'=>'catview','slug' z'+','page'=>'[0-9] +'));



结果页,它只是不工作:

 <?php 
$ slug = $ this-> params ['slug'];
$ this-> Paginator-> options(array('url'=> array('controller'=>'Product',
'action'=>'catview' slug'=> $ slug)));

echo $ this-> Paginator-> prev('< 。 $ this-> Paginator-> next('Show me more>>',array('class'=>'next')); ?>

它不会更改结果,它显示与第1页相同的结果。

解决方案

感谢 AD7six 作为参考。



我的控制器需要具有:

  $ this-> paginate = array(
// other stuff here
'paramType'=> 'querystring'
);

其后:

  $ this-> Paginator-> options(array('url'=> array('controller'=>'Product',
'action'=>'catview' ,'slug'=> $ slug),
'convertKeys'=> array('page')));

I have a list of categories which displays the list of items under it.

Thus:

routes have:

Router::connect('/category/:slug', array('controller' => 'Product',
             'action'=>'catview', 'slug'=> '[0-9a-zA-Z]+'));
Router::connect('/category/:slug/:page', array('controller' => 'Product',
             'action'=>'catview','slug'=> '[0-9a-zA-Z]+','page'=>'[0-9]+'));

and

when I do this in results page, it just doesn't work:

<?php 
        $slug = $this->params['slug'];
        $this->Paginator->options(array('url'=> array('controller' => 'Product',
                             'action'=>'catview','slug'=> $slug)));

        echo $this->Paginator->prev('<< Show me previous', array('class'=>'prev'))
        . $this->Paginator->next('Show me more >>', array('class'=>'next')); ?>

It does not change the results, it shows the same result as it does on page 1.

Any ideas where I am going wrong?

解决方案

Thanks to AD7six for the reference.

My controller needs to have :

$this->paginate = array(
 //other stuff here
 'paramType' => 'querystring'
);

Followed by:

$this->Paginator->options(array('url'=> array('controller' => 'Product',
                                  'action'=>'catview','slug'=> $slug),
                                     'convertKeys' => array('page')));

in the view file

这篇关于如何传递分页参数与附加params cakephp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆