帝国CMS二次开发搜索伪静态教程
帝国CMS搜索伪静态教程步骤:
1、打开esearchindex.php 411行左右,找到:
1 | Header("Location:result/?searchid=$searchid".$dogetvar); |
修改为:
1 | Header("Location:$public_r[newsurl]search-0-$searchid.html".$dogetvar); |
二、打开esearchresultindex.php 20行左右,找到:
1 2 | //搜索结果 $searchid=(int)$_GET['searchid']; |
在前面添加分页函数:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | //增加分页函数 function page10($num,$line,$page_line,$start,$page,$search){ global $fun_r; if($num<=$line) { return ''; } $search=RepPostStr($search,1); $url=$public_r['newsurl'].'search'; $snum=2;//最小页数 $totalpage=ceil($num/$line);//取得总页数 $firststr='< a title = "'.$fun_r['trecord'].'" > '.$num.' </ a > '; //上一页 if($page<>0) { $toppage='< a href = "'.$url.'-0-'.$search.'.html" >'.$fun_r['startpage'].'</ a > '; $pagepr=$page-1; $prepage='< a href = "'.$url.'-'.$pagepr.'-'.$search.'.html" >'.$fun_r['pripage'].'</ a >'; } //下一页 if($page!=$totalpage-1) { $pagenex=$page+1; $nextpage=' < a href = "'.$url.'-'.$pagenex.'-'.$search.'.html" >'.$fun_r['nextpage'].'</ a >'; $lastpage=' < a href = "'.$url.'-'.($totalpage-1).'-'.$search.'.html" >'.$fun_r['lastpage'].'</ a >'; } $starti=$page-$snum< 0 ?0:$page-$snum; $ no = 0 ; for($i=$starti;$i<$totalpage&&$no<$page_line;$i++) { $no++; if($page==$i) { $is_1="<b>"; $is_2="</ b >"; } else { $is_1='< a href = "'.$url.'-'.$i.'-'.$search.'.html" >'; $is_2="</ a >"; } $pagenum=$i+1; $returnstr.=" ".$is_1.$pagenum.$is_2; } $returnstr=$firststr.$toppage.$prepage.$returnstr.$nextpage.$lastpage; return $returnstr; } |
然后在48行左右找到:
1 | $listpage=page1($num,$line,$page_line,$start,$page,$search); |
修改为
1 | $listpage=page10($num,$line,$page_line,$start,$page,$search); |
修改:
1 | $search="&searchid=".$searchid; |
为
1 | $search="$searchid"; |
三、添加伪静态规则(例子为Apache,自己修改为对应的)
#搜索
1 | RewriteRule ^search-(.+?)-(.+?).html$ /e/search/result/index.php?page=$1&searchid=$2 |
四、修改搜索模板中的提交地址为绝对地址:
比如
1 | < form action = 'http://www.11px.cn/e/search/index.php' method = "post" name = "search_news" id = "search_news" > |
提示:不建议使用相对地址。
上一篇:帝国CMS自定义JS语法集合