<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                >[success] ### 第三難 ThinkPHP自定義分頁模板 >[info] ### 默認分頁模板 ![](https://box.kancloud.cn/e62f97e2699a9355038e4fdf8645ad24_586x316.png) >[info] ### 自定義分頁模板 * 項目鏈接:http://pan.baidu.com/s/1miIIcmG 密碼:wwnl ![](https://box.kancloud.cn/ff14988e37b002a6f3e2379b3c14b305_666x321.png) ~~~php <?php namespace tool; use think\Paginator; class TpPageHelper extends Paginator { //TODO : 中間按鈕個數 protected $bnumber = 10; //TODO : 首頁 protected function getfirstButton($str = '') { if ($this->currentPage() <= 1) { return $this->getDisabledTextWrapper($str); } $url = $this->url(1); return $this->getPageLinkWrapper($url, $str); } //TODO : 上一頁 protected function getPreviousButton($text = "&laquo;") { if ($this->currentPage() <= 1) { return $this->getDisabledTextWrapper($text); } $url = $this->url( $this->currentPage() - 1 ); return $this->getPageLinkWrapper($url, $text); } //TODO : 頁碼 protected function getLinks() { if ($this->total > $this->listRows) { if ($this->lastPage < $this->bnumber) { return $this->getUrlLinks($this->getUrlRange(1, $this->lastPage)); } else { $min = 1; if ($this->currentPage > $this->bnumber / 2) $min = $this->currentPage - floor($this->bnumber / 2); if ($this->lastPage - $this->currentPage < $this->bnumber / 2) $min = $this->lastPage - $this->bnumber + 1; return $this->getUrlLinks($this->getUrlRange($min, $min + $this->bnumber - 1)); } } } //TODO : 下一頁 protected function getNextButton($text = '&raquo;') { if (!$this->hasMore) { return $this->getDisabledTextWrapper($text); } $url = $this->url($this->currentPage() + 1); return $this->getPageLinkWrapper($url, $text); } //TODO : 末頁 protected function getlastButton($text = '') { if (!$this->hasMore) { return $this->getDisabledTextWrapper($text); } $url = $this->url($this->lastPage()); return $this->getPageLinkWrapper($url, $text); } //TODO : 渲染頁 public function render() { //數據是否足夠分頁 if ($this->hasPages()) { return sprintf( '<ul class="btn-item fr">%s %s %s %s %s</ul>', $this->getfirstButton('首頁'), $this->getPreviousButton('上一頁'), $this->getLinks(), $this->getNextButton('下一頁'), $this->getlastButton('末頁') ); } } //TODO : 生成禁用按鈕 protected function getDisabledTextWrapper($text) { return '<li class="disabled"><span>' . $text . '</span></li>'; } //TODO : 生成普通按鈕 protected function getPageLinkWrapper($url, $page) { if ($page == $this->currentPage()) { return $this->getActivePageWrapper($page); } return $this->getAvailablePageWrapper($url, $page); } //TODO : 生成當前頁按鈕 protected function getActivePageWrapper($text) { return '<li class="active"><span>' . $text . '</span></li>'; } //TODO : 可點擊按鈕 protected function getAvailablePageWrapper($url, $page) { return '<li><a href="' . htmlentities($url) . '">' . $page . '</a></li>'; } //TODO : 批量生成頁碼按鈕 protected function getUrlLinks(array $urls) { $html = ''; foreach ($urls as $page => $url) { $html .= $this->getPageLinkWrapper($url, $page); } return $html; } } ~~~ * 將 TpPageHelper.php 放在extend\tool下 ![](https://box.kancloud.cn/d2f9796713cadd91d6fc66d371d7c634_225x73.png) * 修改默認模板 ![](https://box.kancloud.cn/0e0f5f5427c7c5fedbf205d510b00f5d_850x305.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看