thinkPHP 分页样式增加下拉列表

$linkPage="  <select name='sldd' style='width:40px;height:30px;border:1px red block;' onchange='location.href=this.options[this.selectedIndex].value;'>";
        
        for($i=1;$i<=$this->totalPages;$i++)//rollpages=>totalPages
        {
            if(($this->nowPage - $now_cool_page) <= 0 )
            {
                $page = $i;
            }
            elseif(($this->nowPage + $now_cool_page - 1) >= $this->totalPages)
            {
                $page = $this->totalPages + $i;
            }
            else
            {
                $page = $this->nowPage - $now_cool_page_ceil + $i;
            }
        
            if($page!=$this->nowPage)
            {
                if($page<=$this->totalPages)
                {
                    $linkPage .= "<option value='".$this->url($page)."'>".$page."</option>";
                }else{
                    break;
                }
            }else{
                if($this->totalPages != 1)
                {
                    $linkPage .= "<option value='".$this->url($page)."' selected='selected'>".$page."</option>";
                }
            }
        }
        $linkPage.="</select>";

$page_str = str_replace(
            array('%HEADER%', '%NOW_PAGE%', '%UP_PAGE%', '%DOWN_PAGE%', '%FIRST%', '%LINK_PAGE%', '%END%', '%TOTAL_ROW%', '%TOTAL_PAGE%','%SELECT_PAGE%'),
            array($this->config['header'], $this->nowPage, $up_page, $down_page, $the_first, $link_page, $the_end, $this->totalRows, $this->totalPages,$linkPage),
            $this->config['theme']);
return "<div class='pager'>{$page_str}</div>";

 

        $p = new \Think\Page($article_sum,C(PAGESIZE));
        $p->rollPage = 1;
        $p->setConfig('header', '<li class="rows">共<b>%TOTAL_ROW%</b>条记录&nbsp;第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</li><li>%SELECT_PAGE%</li>');
        $p->setConfig('prev', '上一页');
        $p->setConfig('next', '下一页');
        $p->setConfig('last', '末页');
        $p->setConfig('first', '首页');
        $p->setConfig('theme', '%FIRST%%UP_PAGE%%LINK_PAGE%%DOWN_PAGE%%END%%HEADER%','%SELECT_PAGE%');
        
        $article_info=array_slice($article_info,$p->firstRow,$p->listRows);
        $this->assign('page',$p->show());

 

posted on 2017-09-05 11:19  *孤独的夜行者*  阅读(259)  评论(0编辑  收藏  举报

导航