当前位置:首页 > 文章 > 帝国CMS > 正文内容

帝国CMS搜索页伪静态实现方法

3年前 (2022-10-22)帝国CMS6365

本文介绍帝国CMS搜索页url伪静态实现方法,可实现帝国CMS站内搜索结果页的伪静态显示,在使用帝国CMS二次开发中非常具有实用价值,需要的朋友可以参考下(文末附iis解决方案)

具体实现方法如下:

一、打开\e\search\index.php 411行左右,找到:

Header("Location:result/?searchid=$searchid".$dogetvar);

修改为:

Header("Location:$public_r[newsurl]search-0-$searchid.html".$dogetvar);

二、打开\e\search\result\index.php 20行左右,找到:

//搜索结果
$searchid=(int)$_GET['searchid'];

在前面添加分页函数:

//增加分页函数
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 >&nbsp;'.$num.'&nbsp;</a>&nbsp;&nbsp;';
//上一页
if($page<>0)
{
$toppage='<a href="'.$url.'-0-'.$search.'.html">'.$fun_r['startpage'].'</a>&nbsp;';
$pagepr=$page-1;
$prepage='<a href="'.$url.'-'.$pagepr.'-'.$search.'.html">'.$fun_r['pripage'].'</a>';
}
//下一页
if($page!=$totalpage-1)
{
$pagenex=$page+1;
$nextpage='&nbsp;<a href="'.$url.'-'.$pagenex.'-'.$search.'.html">'.$fun_r['nextpage'].'</a>';
$lastpage='&nbsp;<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.="&nbsp;".$is_1.$pagenum.$is_2;
}
$returnstr=$firststr.$toppage.$prepage.$returnstr.$nextpage.$lastpage;
return $returnstr;
}

 

然后在48行左右找到:

$listpage=page1($num,$line,$page_line,$start,$page,$search);

修改为:

$listpage=page10($num,$line,$page_line,$start,$page,$search);

找到:

$search="&searchid=".$searchid;

修改为:

$search="$searchid";

 

三、添加伪静态规则(例子为Apache,自己修改为对应的).

RewriteRule ^search-(.+?)-(.+?)\.html$ /e/search/result/index\.php\?page=$1&searchid=$2
.htaccess文件参考代码
RewriteEngine on
RewriteRule ^c-(.+?)-(.+?)\.html$ /e/search/result/index\.php\?page=$1&searchid=$2

 

 

四、修改搜索模板中的提交地址为绝对地址:

<form action='http://www.XXXX.com/e/search/index.php' method="post" name="search_news" id="search_news">

IIS伪静态方法:

https://www.cnblogs.com/ytkah/p/6893217.html

帝国CMS搜索页伪静态实现方法

扫描二维码推送至手机访问。

版权声明:本文由蓝博发布,如需转载请注明出处。

本文链接:https://blueboss.cn/p/728.shtml

“帝国CMS搜索页伪静态实现方法” 的相关文章

帝国cms内容页正文附件下载的调用代码

帝国cms内容页正文附件下载的调用代码

帝国cms内容页正文附件下载的调用代码 [e:loop={"select * from phome_enewsfile_1 where classid='$navinfor[classid]' and id='$navinfor[id]' order by id desc",0,24,0,'','...

帝国CMS使用esub/substr截取前面(或后面)两个字符(或多个字符)

帝国CMS使用esub/substr截取前面(或后面)两个字符(或多个字符)

帝国CMS怎么用灵动标签使用esub/substr截取前面,或者截取后面两个字符或者多个字符呢? ①、帝国网站 显示是"帝国" (这是灵动标签默认的截取标签字段“esub”), [e:loop={'select * from phome_enewsclass where bclassid=0 or...

帝国CMS内容页调用指定ID的文章可以指定多篇

帝国CMS内容页调用指定ID的文章可以指定多篇

帝国CMS内容页中调用多篇指定id文章的方法,下面一起来学习学习吧: 大概的思路是: 新建1个产品文章字段,这样的话,每个产品里面都可以填写不同的产品id,然后在模板里面调用出来即可。 下面附上内容页模板里面调用多篇指定文章id的php代码: <?php $sql='id in ('.$na...

帝国CMS用灵动标签调用简介截取字数

帝国CMS用灵动标签调用简介截取字数

帝国CMS灵动标签调用文章缩略图的标签写法: <?=$bqr[smalltext]?> <?=esub($bqr[smalltext],50)?> (上面标签注释:该标签可限制内容简介显示的字数,举例中的50表示显示50个字符,算城成是汉字就是25个字,大家可以根据自己的...

帝国CMS灵动标签loop调用TAG标签

帝国CMS灵动标签loop调用TAG标签

帝国CMS怎么用灵动标签调用TAG标签呢 代码如下: [e:loop={0,10,3,1,'','newstime DESC'}] <?php $newbook1=$empire->query("select * from phome_ecms_news_data_1 where id...

帝国CMS模板怎么禁止鼠标右键菜单和复制功能

帝国CMS模板怎么禁止鼠标右键菜单和复制功能

帝国cms模板如何禁止鼠标、鼠标右键和复制功能,这样可以避免一些只知道复制的网站增加原始内容的强度。 正如模板的确认所知,模板中页面的内容从html主体标记中的代码开始。我们只需要另一个代码来实现屏幕上的鼠标右键:oncontextmenu=self.event.returnValue=false...