CakePHP分页和获取参数 [英] CakePHP pagination and the get parameters

查看:88
本文介绍了CakePHP分页和获取参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的搜寻网页中有分页的问题。
当用户搜索某个东西我有一个url像 domain.com/search/?s=keyword
,但paginator给我的链接,例如 domain.com/search/page:x
所以在next和prev和numbers页面中get参数丢失。我需要配置paginator获得链接,如 domain.com/search/page:x/?s=keyword
但是我不能这样做。 p>

我需要知道如何配置

  $ paginator-> (); 
$ paginator-> next();
$ paginator-> prev();
$ paginator-> numbers();

以获得所需的效果。
Thanx。

解决方案

创建选项数组

  $ options = array(
'url'=> array(
'controller'=>'posts',
'action'=> 'search',
'?'=>'keyword ='。$ keyword

);

将其设为助手

  $ paginator-> options($ options)

可以使用paginator helper,同时保留GET变量。



希望它能帮助:)



更容易你可以在你的视图或.ctp文件中putl $ paginator选项

  $ this-> Paginator-& url'] ['?'] = $ this-> params ['ur]; 

然后输入您想要的值:)


I have a problem with the pagination in my search page. When a user search something I have a url like domain.com/search/?s=keyword but paginator gives me links like domain.com/search/page:x, so in the next and prev and numbers page the get parameter is lost. I need to configure paginator to get links like domain.com/search/page:x/?s=keyword But I can't do this.

I need to know how to configure

$paginator->options();
$paginator->next();
$paginator->prev();
$paginator->numbers();

to get the needed efect. Thanx.

解决方案

create the options array

$options = array(
    'url'=> array(
        'controller' => 'posts', 
        'action' => 'search', 
        '?' => 'keyword='.$keyword
     )
);

set it to the helper

$paginator->options($options)

and then you can use the paginator helper while retaining the GET variables.

hope that it helped :)

to make it easier you can putl $paginator options in your view or .ctp file

$this->Paginator->options['url']['?'] = $this->params['ur];

then put the value that you want :)

这篇关于CakePHP分页和获取参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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