2016-11-16 38 views
2

我使用cakephp 3.x paginator,並且我有一個來自客戶的請求。Cakephp paginator與多個頁面跳轉

例子:

  • 我PAGINATE吧,現在它站在#1。

<< | < | **1** 2 3 4 5 6 7 8 9 | > | >>

  • 當我點擊 「>>」 欄將顯示10-19,並站在10號

<< | < | **10** 11 12 13 14 15 16 17 18 19 | > | >>

  • 點擊「> >「,它將顯示20-29,並站在#20

<< | < | **20** 21 22 23 24 25 26 27 28 29 | > | >>

  • 同樣的, 「< <」,會回到10-19和1-9。

的 「>」 和 「<」 只是去下一個頁面,並返回到上一個頁面。

所以我的問題是:

  • 我怎樣才能使 「>>」 和 「< <」 按鈕,CakePHP的分頁幫手?

我在view.ctp代碼

<?php 
    echo $this->Paginator->first(<<); 

    echo $this->Paginator->prev('<'); 

    echo $this->Paginator->numbers(); 

    echo $this->Paginator->next('>'); 

    echo $this->Paginator->last(>>); 
?> 
+0

使用單/雙引號'<<' and '>>'...'第一( '<<')','最後('>>')' – Poonam

+0

對不起,我不明白你的意思。 – TommyDo

+0

用這個'echo $ this-> Paginator-> first('<<');'替換這個'echo $ this-> Paginator-> first(<<);'並且與'last'相同 – Poonam

回答

1

遺憾的是沒有內置,將創建這樣的鏈接分頁程序的輔助方法,你可能要爲file a feature request,我認爲這將是一個很好的補充。

也就是說,您可以手動創建這樣的跳轉鏈接,paginator助手提供了所需的所有內容,即當前頁碼,檢查給定頁面是否存在的方法以及用於從助手模板。

這裏有一個簡單的例子,這將產生一個跳轉鏈接,當前頁面+ 10的情況下,存在頁:

$page = $this->Paginator->current() + 10; 
if ($this->Paginator->hasPage($page)) { 
    echo $this->Paginator->templater()->format('nextActive', [ 
     'url' => $this->Paginator->generateUrl(['page' => $page]), 
     'text' => '>>', 
    ]); 
} 

參見

Templater docs are currently missing出於某種原因...