cakephp 1.3,如何对两列使用Paginator-& gt; sort()? [英] cakephp 1.3, how to use Paginator->sort() for two columns?

查看:63
本文介绍了cakephp 1.3,如何对两列使用Paginator-& gt; sort()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的应用程序,其中我查看数据库中的一些帖子,并使用 Paginator-> sort 进行排序.

i have a simple application where i view some posts from a database and i use Paginator->sort to sort.

我所做的是我重复了所有工作,以便我显示帖子两次以及进行排序.像这样的东西:

What i did is i duplicate everything so that i show the posts twice as well as the sorting. something like this:

link_sort
post1
post2
post3
link_sort
post1
post2
post3

但是当我单击 link_sort 时,两个帖子的显示都会被排序,我可以看到,因为它们是相同的.但是我如何使其独特,以便一个链接对一个帖子显示进行排序,而另一个对另一个帖子进行排序:).

But when i click link_sort both post display get sorted, and i could see that because they are the same. But how can i make it unique so that one link sorts one post display and another one the other one :).

下面是一些代码:

<div class="sort"><?php echo $this->Paginator->sort('title');?></div>
<div class="sort"><?php echo $this->Paginator->sort('body');?></div>
<div class="content_title"><?php echo $post['Post']['title']; ?></div>
<div class="content_body"><?php echo $post['Post']['body']; ?></div>

<div class="sort"><?php echo $this->Paginator->sort('title');?></div>
<div class="sort"><?php echo $this->Paginator->sort('body');?></div>
<div class="content_title"><?php echo $post['Post']['title']; ?></div>
<div class="content_body"><?php echo $post['Post']['body']; ?></div>

有什么想法吗?谢谢

推荐答案

我认为这会起作用-在控制器中创建两个不同的变量:

I think this will work - create two different variables in the controller:

$ paginate1 = $ this-> paginate('conditions ...') $ paginate2 = $ this-> paginate('conditions ...')

如果没记错的话,我曾经有过类似的问题,这就是我解决的方法.

if am not mistaken I had a similar problem once and this is how I solved it.

这篇关于cakephp 1.3,如何对两列使用Paginator-&amp; gt; sort()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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