2012-10-23 80 views
1

好吧,所以基本上我已经创建了一个简单的页面使用Kohana显示用户的消息收件箱/发件箱使用标签。Kohana分页和JavaScript标签

我的控制器是这样的:

$content     = View::factory('messages')->bind('user', $user)->bind('received', $received)->bind('sent', $sent)->bind('pager_links', $pager_links); 
$user     = Auth::instance()->get_user(); 
$message_count   = ORM::factory('message')->where('to_id', '=', $user)->where('read', '=', '0')->count_all(); 
$pagination    = Pagination::factory(array(
    'total_items' => $message_count, 
    'items_per_page' => 10 
)); 
$received    = ORM::factory('messages')->where('messages.to_id', '=', $user)->limit($pagination->items_per_page)->offset($pagination->offset)->find_all(); 
$sent     = ORM::factory('messages')->where('messages.user_id', '=', $user)->limit($pagination->items_per_page)->offset($pagination->offset)->find_all(); 
$pager_links    = $pagination->render(); 
$this->template->content = $content; 

到目前为止,我只显示收到的消息和分页视图,它是工作的罚款。不过,我想实现一个标签容器,以在同一页面上显示收到和发送的项目。

我在摸我的脑袋,想知道如何使用每个标签的分页方面,而不影响两个标签。使用现有方法的最佳方向是什么?也许抛出一个附加参数到当标签被选中的网址...

感谢

回答

1

基本上你的问题是,你不能一次在查询字符串中使用page两个标签,因为很明显它会影响分页功能。幸运的是,实际上有一个配置打开,允许您在查询字符串中指定current page参数的来源。

尝试......

$pagination    = Pagination::factory(array(
    'current_page' => array('source' => 'query_string', 'key' => 'tab1_page'), 
    'total_items' => $message_count, 
    'items_per_page' => 10 
)); 

然后,所有你需要做的是确保你的分页视图传递页码正确的参数在查询字符串如http://mydomain.com/pagewithtabs?tab1_page=2&tab2_page=3会将第2页的标签1和第3页的标签2.

希望帮助!