2012-10-23 78 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.

希望幫助!