织梦搜索结果页分页条样式修改

2021年3月18日17:01:49 发表评论
广告也精彩

织梦搜索结果页里的分页是跟栏目列表页的分页是2个完全不同样式的,为了美观整站统一分页样式,我们可以用css大难度的实现,也可以修改PHP文件来实现

下面介绍修改PHP文件来实现

打开 /include/arc.searchview.class.php 找到 ,大概在532行左右

  1. $this->dtp->Assign($tagid,$this->GetPageListDM($list_len));

改成

  1. $ctag->GetAtt("listitem")=="" ? $listitem="index,pre,pageno,next,end,option" : $listitem=$ctag->GetAtt("listitem");
  2. $this->dtp->Assign($tagid,$this->GetPageListDM($list_len,$listitem));

继续找到 ,大概在 812 行左右

  1. function GetPageListDM($list_len)

把整个函数改成

  1. function GetPageListDM($list_len,$listitem="index,end,pre,next,pageno")
  2. {
  3.     global $oldkeyword;
  4.     $prepage="";
  5.     $nextpage="";
  6.     $prepagenum = $this->PageNo - 1;
  7.     $nextpagenum = $this->PageNo + 1;
  8.     if($list_len=="" || preg_match("/[^0-9]/"$list_len))
  9.     {
  10.         $list_len=3;
  11.     }
  12.     $totalpage = ceil($this->TotalResult / $this->PageSize);
  13.     if($totalpage<=1 && $this->TotalResult>0)
  14.     {
  15.         return "<li><span class=\"pageinfo\">共 1 页 / ".$this->TotalResult." 条记录</span></li>\r\n";
  16.     }
  17.     if($this->TotalResult == 0)
  18.     {
  19.         return "<li><span class=\"pageinfo\">共 0 页/ ".$this->TotalResult." 条记录</span></li>\r\n";
  20.     }
  21.     $maininfo = "<li><span class=\"pageinfo\">共 <strong>{$totalpage}</strong>页 <strong>".$this->TotalResult."</strong>条</span></li>\r\n";
  22.     $purl = $this->GetCurUrl();
  23.     $oldkeyword = (emptyempty($oldkeyword) ? $this->Keyword : $oldkeyword);
  24.     //当结果超过限制时,重设结果页数
  25.     if($this->TotalResult > $this->SearchMaxRc)
  26.     {
  27.         $totalpage = ceil($this->SearchMaxRc/$this->PageSize);
  28.     }
  29.     $geturl = "keyword=".urlencode($oldkeyword)."&searchtype=".$this->SearchType;
  30.     $geturl .= "&channeltype=".$this->ChannelType."&orderby=".$this->OrderBy;
  31.     $geturl .= "&kwtype=".$this->KType."&pagesize=".$this->PageSize;
  32.     $geturl .= "&typeid=".$this->TypeID."&TotalResult=".$this->TotalResult."&";
  33.     $purl .= "?".$geturl;
  34.     //获得上一页和下一页的链接
  35.     if($this->PageNo != 1)
  36.     {
  37.         $prepage.="<li><a href='".$purl."PageNo=$prepagenum'>上一页</a></li>\r\n";
  38.         $indexpage="<li><a href='".$purl."PageNo=1'>首页</a></li>\r\n";
  39.     }
  40.     else
  41.     {
  42.         $indexpage="<li><a href='".$purl."PageNo=1'>首页</a></li>\r\n";
  43.     }
  44.     if($this->PageNo!=$totalpage && $totalpage>1)
  45.     {
  46.         $nextpage.="<li><a href='".$purl."PageNo=$nextpagenum'>下一页</a></li>\r\n";
  47.         $endpage="<li><a href='".$purl."PageNo=$totalpage'>末页</a></li>\r\n";
  48.     }
  49.     else
  50.     {
  51.         $endpage="<li><a href='".$purl."PageNo=$totalpage'>末页</a></li>\r\n";
  52.     }
  53.     //获得数字链接
  54.     $listdd="";
  55.     $total_list = $list_len * 2 + 1;
  56.     if($this->PageNo >= $total_list)
  57.     {
  58.         $j = $this->PageNo - $list_len;
  59.         $total_list = $this->PageNo + $list_len;
  60.         if($total_list > $totalpage)
  61.         {
  62.             $total_list = $totalpage;
  63.         }
  64.     }
  65.     else
  66.     {
  67.         $j=1;
  68.         if($total_list > $totalpage)
  69.         {
  70.             $total_list = $totalpage;
  71.         }
  72.     }
  73.     for($j$j<=$total_list$j++)
  74.     {
  75.         if($j == $this->PageNo)
  76.         {
  77.             $listdd.= "<li class=\"thisclass\"><a href='".$purl."PageNo=$j'>$j</a></li>\r\n";
  78.         }
  79.         else
  80.         {
  81.             $listdd.="<li><a href='".$purl."PageNo=$j'>$j</a></li>\r\n";
  82.         }
  83.     }
  84.     $plist = '';
  85.     if(preg_match('/index/i', $listitem)) $plist .= $indexpage;
  86.     if(preg_match('/pre/i', $listitem)) $plist .= $prepage;
  87.     if(preg_match('/pageno/i', $listitem)) $plist .= $listdd;
  88.     if(preg_match('/next/i', $listitem)) $plist .= $nextpage;
  89.     if(preg_match('/end/i', $listitem)) $plist .= $endpage;
  90.     if(preg_match('/option/i', $listitem)) $plist .= $optionlist;
  91.     if(preg_match('/info/i', $listitem)) $plist .= $maininfo;
  92.     return $plist;
  93. }

搜索结果页 分页条标签写法(跟栏目列表分页标签一样)

  1. <div class="dede_pages">
  2.     <ul class="pagelist">
  3.         {dede:pagelist listitem="index,end,pre,next,pageno,info" listsize="5"/}
  4.     </ul>
  5. </div>

 

 

 

 



微信扫描下方的二维码阅读本文

ts小陈

发表评论(不允许含有网址!)

:?: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :cry: :mrgreen: :neutral: :razz:

已登录用户不需要填写以下内容