cakephp 1.3, how to use Paginator->sort() for two columns?

被刻印的时光 ゝ 提交于 2019-12-11 11:58:05

问题


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

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 :).

here is some code:

<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>

any ideas? thanks


回答1:


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.



来源:https://stackoverflow.com/questions/6644094/cakephp-1-3-how-to-use-paginator-sort-for-two-columns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!