开发者

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

开发者 https://www.devze.com 2023-03-19 10:29 出处:网络
i have a simple application where i view some posts from a database and i use Paginator->sort to 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

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 $t开发者_如何学运维his->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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消