Bootstrap 织梦搜索列表分页

找到 include 下的 arc.searchview.class.php

并找到该代码段

 

将其他方法替换为:

    /**
     *  获取动态的分页列表
     *
     * @access    public
     * @param     string  $list_len  列表宽度
     * @return    string
     */
    function GetPageListDM($list_len)
    {
        global $oldkeyword;
        $prepage="";
        $nextpage="";
        $prepagenum = $this->PageNo - 1;
        $nextpagenum = $this->PageNo + 1;
        if($list_len=="" || preg_match("/[^0-9]/", $list_len))
        {
            $list_len=3;
        }
        $totalpage = ceil($this->TotalResult / $this->PageSize);
        if($totalpage<=1 && $this->TotalResult>0)
        {
            return "<ul class=\"pagination\"><li class=\"disabled\"><a>共1页/".$this->TotalResult."条记录</a></li></ul>";
        }
        if($this->TotalResult == 0)
        {
            return "<ul class=\"pagination\"><li class=\"disabled\"><a>共0页/".$this->TotalResult."条记录</a></li></ul>";
        }
        $purl = $this->GetCurUrl();
        
        $oldkeyword = (empty($oldkeyword) ? $this->Keyword : $oldkeyword);

        //当结果超过限制时,重设结果页数
        if($this->TotalResult > $this->SearchMaxRc)
        {
            $totalpage = ceil($this->SearchMaxRc/$this->PageSize);
        }
        $infos = "<li><a>共找到<b>".$this->TotalResult."</b>条记录/最大显示<b>{$totalpage}</b>页 </a></li>\r\n";
        $geturl = "keyword=".urlencode($oldkeyword)."&searchtype=".$this->SearchType;
        $hidenform = "<input type='hidden' name='keyword' value='".rawurldecode($oldkeyword)."'>\r\n";
        $geturl .= "&channeltype=".$this->ChannelType."&orderby=".$this->OrderBy;
        $hidenform .= "<input type='hidden' name='channeltype' value='".$this->ChannelType."'>\r\n";
        $hidenform .= "<input type='hidden' name='orderby' value='".$this->OrderBy."'>\r\n";
        $geturl .= "&kwtype=".$this->KType."&pagesize=".$this->PageSize;
        $hidenform .= "<input type='hidden' name='kwtype' value='".$this->KType."'>\r\n";
        $hidenform .= "<input type='hidden' name='pagesize' value='".$this->PageSize."'>\r\n";
        $geturl .= "&typeid=".$this->TypeID."&TotalResult=".$this->TotalResult."&";
        $hidenform .= "<input type='hidden' name='typeid' value='".$this->TypeID."'>\r\n";
        $hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."'>\r\n";
        $purl .= "?".$geturl;

        //获得上一页和下一页的链接
        if($this->PageNo != 1)
        {
            $prepage.="<li><a href='".$purl."PageNo=$prepagenum'>&laquo;</a></li>\r\n";
            $indexpage="<li><a href='".$purl."PageNo=1'>首页</a></li>\r\n";
        }
        else
        {
            $indexpage="<li class=\"disabled\"><a href='".$purl."PageNo=1'>首页</a></li>\r\n";
        }
        if($this->PageNo!=$totalpage && $totalpage>1)
        {
            $nextpage.="<li><a href='".$purl."PageNo=$nextpagenum'>&raquo;</a></li>\r\n";
            $endpage="<li><a href='".$purl."PageNo=$totalpage'>末页</a></li>\r\n";
        }
        else
        {
            $endpage="<li class=\"disabled\"><a href='".$purl."PageNo=$totalpage'>末页</a></li>\r\n";
        }

        //获得数字链接
        $listdd="";
        $total_list = $list_len * 2 + 1;
        if($this->PageNo >= $total_list)
        {
            $j = $this->PageNo - $list_len;
            $total_list = $this->PageNo + $list_len;
            if($total_list > $totalpage)
            {
                $total_list = $totalpage;
            }
        }
        else
        {
            $j=1;
            if($total_list > $totalpage)
            {
                $total_list = $totalpage;
            }
        }
        for($j; $j<=$total_list; $j++)
        {
            if($j == $this->PageNo)
            {
                $listdd.= "<li class=\"active\"><a href='".$purl."PageNo=$j'>".$j."</a></li>\r\n";
            }
            else
            {
                $listdd.="<li><a href='".$purl."PageNo=$j'>".$j."</a></li>\r\n";
            }
        }
        
        $plist = "<form name='pagelist' action='".$this->GetCurUrl()."'>$hidenform";
		$plist .=  "<ul class=\"pagination\">\r\n";
		//$plist .= $infos;
		$plist .= $indexpage;
        $plist .= $prepage;
        $plist .= $listdd;
        $plist .= $nextpage;
        $plist .= $endpage;
        $plist .= "</ul>\r\n</form>\r\n";
        return $plist;
    }

在html页面上写

<div class="container">
	<ul class="list-group">
		<li class="list-group-item item-addons"><a class="item-title-addons">搜索 <strong>{dede:global name='keyword' function='RemoveXSS(@me)'/}</strong> 的结果 </a></li>
		{dede:list titlelen='100'}
		<li class="list-group-item line-nowrap"><a href="[field:arcurl /]">[field:title /]</a></li>
		{/dede:list}
	</ul>
	{dede:pagelist listitem="index,end,pre,next,pageno"/}
</div>

效果图:

 

猜你喜欢

转载自onestopweb.iteye.com/blog/2272268
今日推荐