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

帝国cms搜索模板无缓存使用多个搜索模板

3年前 (2022-10-21)帝国CMS11950
网站中用到两个甚至多个搜索模板,在搜索代码中除了会设置指定的模板id以外,还需要更改以下内容,目的就为了解决缓存问题,比如说,用户可能是在搜索“模板”图文列表后,再去搜“教程”,搜索列表显示的还是之前“模板”的搜索模板。提醒大家一定要先备份哟!
教程如下: 将以下内容替换到/e/search/result/index.php
<?php
require('../../class/connect.php');
require('../../class/db_sql.php');
require('../../class/functions.php');
require('../../class/t_functions.php');
require('../../data/dbcache/class.php');
require "../".LoadLang("pub/fun.php");
$editor=1;
eCheckCloseMods('search');//关闭模块
$link=db_connect();
$empire=new mysqlquery();
$getvar=$_GET['getvar'];
if(empty($getvar))
{
    $getfrom="history.go(-1)";
}
else
{
    $getfrom="../../../search/";
}
//搜索结果
$searchid=(int)$_GET['searchid'];
if(empty($searchid))
{
    printerror("SearchNotRecord",$getfrom,1);
}
$search_r=$empire->fetch1("select searchid,keyboard,result_num,orderby,myorder,tbname,tempid,andsql,trueclassid from {$dbtbpre}enewssearch where searchid='$searchid'");
if(empty($search_r['searchid'])||InfoIsInTable($search_r[tbname]))
{
    printerror("SearchNotRecord",$getfrom,1);
}
$page=(int)$_GET['page'];
$page=RepPIntvar($page);
$start=0;
$page_line=$public_r['search_pagenum'];//每页显示链接数
$line=$public_r['search_num'];//每页显示记录数
$offset=$page*$line;//总偏移量
$search="&searchid=".$searchid;
$myorder=$search_r[orderby];
if(empty($search_r[myorder]))
{
    $myorder.=" desc";
}
$add=stripSlashes($search_r['andsql']);
$num=$search_r[result_num];
$query="select * from {$dbtbpre}ecms_".$search_r[tbname].($add?' where '.substr($add,5):'');
$query.=" order by ".$myorder." limit $offset,$line";
$sql=$empire->query($query);
$listpage=page1($num,$line,$page_line,$start,$page,$search);
//取得模板
if($search_r['tempid'])
{
    $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where tempid='".$search_r['tempid']."' limit 1");
}
elseif(empty($class_r[$search_r[trueclassid]][searchtempid]))
{
    $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where isdefault=1 limit 1");
}
else
{
    $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where tempid='".$class_r[$search_r[trueclassid]][searchtempid]."' limit 1");
}
$have_class=1;
//页面支持标签
     
$tempr[temptext]=DtNewsBq('list'.$search_r['tempid'],$tempr[temptext],0);
//替换公共模板变量
$listtemp=$tempr[temptext];
if($public_r['searchtempvar'])
{
    $listtemp=ReplaceTempvar($listtemp);
}
$search_r[keyboard]=ehtmlspecialchars($search_r[keyboard]);
$listtemp=str_replace("[!--show.page--]",$listpage,$listtemp);
$listtemp=str_replace("[!--keyboard--]",$search_r[keyboard],$listtemp);
$listtemp=str_replace("[!--ecms.num--]",$num,$listtemp);
$url="<a href='".ReturnSiteIndexUrl()."'>".$fun_r['index']."</a>&nbsp;>&nbsp;".$fun_r['adsearch'];
$pagetitle=$fun_r['adsearch']." ".$search_r[keyboard];
$listtemp=ReplaceSvars($listtemp,$url,0,$pagetitle,$pagetitle,$pagetitle,$add,0);
$rownum=$tempr[rownum];
if(empty($rownum))
{
    $rownum=1;
}
$formatdate=$tempr[showdate];
$subnews=$tempr[subnews];
$subtitle=$tempr[subtitle];
$docode=$tempr[docode];
$modid=$tempr[modid];
$listvar=str_replace('[!--news.url--]',$public_r[newsurl],$tempr[listvar]);
//字段
$ret_r=ReturnReplaceListF($tempr[modid]);
//取得列表模板
$list_exp="[!--empirenews.listtemp--]";
$list_r=explode($list_exp,$listtemp);
$listtext=$list_r[1];
$no=$offset+1;
$changerow=1;
while($r=$empire->fetch($sql))
{
    //替换列表变量
    $repvar=ReplaceListVars($no,$listvar,$subnews,$subtitle,$formatdate,$url,$have_class,$r,$ret_r,$docode);
    $listtext=str_replace("<!--list.var".$changerow."-->",$repvar,$listtext);
    $changerow+=1;
    //超过行数
    if($changerow>$rownum)
    {
        $changerow=1;
        $string.=$listtext;
        $listtext=$list_r[1];
    }
    $no++;
}
db_close();
$empire=null;
//多余数据
if($changerow<=$rownum&&$listtext<>$list_r[1])
{
    $string.=$listtext;
}
$string=$list_r[0].$string.$list_r[2];
echo stripSlashes($sring);
?>

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

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

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

“帝国cms搜索模板无缓存使用多个搜索模板” 的相关文章

IIS环境下开启TAG伪静态帝国CMS的中文TAG提示此TAG不存在

IIS环境下开启TAG伪静态帝国CMS的中文TAG提示此TAG不存在

用帝国cms制作网站或者搬家后,IIS环境下开启TAG伪静态,帝国CMS的中文TAG提示此TAG不存在,是什么问题呢?解决方案: 打开/e/tags/index.php文件 查找: $tagname=RepPostVar($_GET['tagname']); 修改为 $tagname=RepPo...

帝国CMS上传生成的随机文件名前面增加自定义前缀

帝国CMS上传生成的随机文件名前面增加自定义前缀

帝国CMS上传生成的随机文件名前面怎么实现增加自定义前缀呢?如何实现?帝国CMS默认上传文件后生成一个32位的随机名称,今天教大家的方法可以在这个32位的随机名称前增加固定名称。 比如,增加 lexiw_ 那么生成后的文件名称就是: lexiw_3445645iuiu567567u5pou5675...

帝国cms模板内容页SQl调用当前TAG标签

帝国cms模板内容页SQl调用当前TAG标签

帝国cms内容页SQl方式调用当前TAG标签的方式 具体调用代码如下: <?php $fr=$empire->fetch1("select infotags from {$dbtbpre}ecms_news_data_{$navinfor[stb]} where id='$navinf...

帝国CMS做单页自定义页面怎么调用

帝国CMS做单页自定义页面怎么调用

做帝国cms模板网时候,经常需要使用到自定义页面,例如我们做单页(比如“公司介绍”、“联系我们”,联系我们等页面)时一般采用自定义页面的方式来做,那么帝国CMS自定义页面怎么调用呢? 调用出自定义页面导航可以用标签SQL调用。如下: 例子1:调用自定义页面分类ID=1的页面导航 [e:loop={...

帝国CMS发布文章替换正文图片标签里ALT内容

帝国CMS发布文章替换正文图片标签里ALT内容

帝国CMS发布信息文章时替换正文IMG图片标签里的ALT内容 有利于网站的SEO优化。 在 e/class/userfun.php 里面增加 //替换正文IMG里的ALT内容 function user_imgalt($mid,$f,$isadd,$isq,$value,$cs){ $title=...

帝国CMS列表页判断文章来源带链接

帝国CMS列表页判断文章来源带链接

帝国CMS列表页内容怎么判断显示文章来源呢?并且来源带链接? 在列表内容模板里面写如下代码即可: $userr=$empire->fetch1("select befrom from {$dbtbpre}ecms_news_data_{$r[stb]} where id='$r[id]'")...