cakePHP分页与post数据没有会话,序列化或post得到 [英] cakePHP paginate with post data without sessions, serialization or post to get

查看:108
本文介绍了cakePHP分页与post数据没有会话,序列化或post得到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个小的搜索和过滤表单方法post在controller / index,它发布到自己的条件和字段分页($ this-> paginate($条件))



然而,这对于第一页是有好处的,随后的页面文件夹条件丢失。分页passArgs支持获取变量。



有没有复杂的方式将发布条件传递给其他分页页面?



已经看过是在会话中传递$条件,这是没有分配会话的复杂性,并且在提交表单时取消设置会话(更多细化用户的过滤器条件)
另一种方法是传递$ condition作为序列化的字符串url_encode作为get参数。



有没有一个好的蛋糕方法做这更像passArgs,会话和url encode不像蛋糕风格。 p>

感谢

解决方案

您可以使用passedArgs。



在方法控制器中:

  if(empty($ this-> passedArgs [' search']);} {
$ this-> passedArgs ['search'] = $ this-> data ['YourModel'] ['search'];
}
if(empty($ this-> data)){
$ this-> data ['YourModel'] ['search'] = $ this-> passedArgs [ '搜索'];
}

  $ this-> Paginator-> options(array('url'=> $ this-> passedArgs)); 


I have created a small search and filter form method post in controller/index, which posts to it self the conditions and fields to paginate ( $this->paginate($conditions) )

However that is good for the first page, the subsequent pages the filer conditions are lost. pagination passArgs supports get variables well.

Is there an un complex way to pass the post conditions to the other paginated pages?

The method I have looked at is pass the $conditions in session , which isnt without complexity of assigning session and unset the session on submitting the form again (more refinements to the filter criteria by the user ) The other method is passing the $conditions as serialized string url_encode as an get parameter.

Is there an good cake way to do this more like passArgs, sessions and url encode do not look like cake style.

Thanks

解决方案

You can use passedArgs.

in the method controller :

if ( empty($this->passedArgs['search']) ){
    $this->passedArgs['search'] = $this->data['YourModel']['search'];
}
if ( empty($this->data) ){
    $this->data['YourModel']['search'] = $this->passedArgs['search'];
}

in your view :

$this->Paginator->options(array('url' => $this->passedArgs));

这篇关于cakePHP分页与post数据没有会话,序列化或post得到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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