LifeType 中文開發論壇

開發 => 核心補強 => 主題作者是: maomaode 於 十一月 19, 2006, 06:39:25 下午



主題: 改善分页显示的格式
作者: maomaode十一月 19, 2006, 06:39:25 下午
1.1 已经加入分页显示, 不过我个人感觉还可以进一步完善,  在1.0时候, bokeland.com 就已经加入了分页, 大家可以察看http://bokeland.bokeland.com 看到效果, 主要的思路是分页不不宜显示太长, 最多显示10个, 同时加上首页和末页.

要达到这个效果, 只需要修改下面这个片段 class/data/pager/pager.class.php:
引用
      function getPageLinks()
      {
          $min_num = 5;

          if ($this->_totalPages <= $min_num) {
            return $this->_pageLinks;
         }

          $start_id = 1;
          $end_id = $this->_totalPages;
 
          if ($this->_curPage >= $min_num) {
            $start_id = $this->_curPage - $min_num + 1;
            $end_id = $this->_curPage + $min_num;
            if ($end_id > $this->_totalPages) {
                  $end_id = $this->_totalPages;
             }
          } else {
            $start_id = 1;
            $end_id = $this->_curPage + $min_num - 1;
            if ($end_id > $this->_totalPages) {
              $end_id = $this->_totalPages;
            }
          }
   
          $decent_pages = array();
          for ($i = $start_id; $i <= $end_id; $i++) {
            $decent_pages[$i] = $this->_pageLinks[$i];
          }
          return $decent_pages;
      }
Hi mark,
不知道是否可以考虑加入到core里面

谢谢!