帝国搜索页面支持调用动态tag的方法

复制以下代码到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('listsearch'.$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);
$listtext=str_replace($search_r[keyboard],"<font color='red'>$search_r[keyboard]</font>",$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($string);
?>

本文摘自网络,不代表短经典网立场 https://www.duanjingdian.com/894.html

上一篇 2024 年 8 月 25 日 上午11:22
下一篇 2024 年 8 月 25 日 上午11:23

相关推荐

  • 帝国CMS8.0版支付接口升级

    帝国CMS8.0版对支付接口进行升级:1、新增微信支付接口(不过不是最新接口版本)。2、支付宝支付接口升级最新接口版本。3、支付接口新增异步支付方式,并且后台可自行选择是否开启。4…

    帝国CMS 2024 年 12 月 3 日
    141
  • 可用在帝国CMS中字符截取函数

    可用两个php函数用来截取字符,帝国由php开发,所以这两个函数也是可以用到帝国上面 1、esub截取: 这个函数就是把一段字符从开始截取显示多少个,比如:<?=esub($…

    帝国CMS 2024 年 5 月 11 日
    278
  • 帝国cms如何在列表页显示栏目关键字?

    帝国cms栏目的关键字词显示标签是[!--class.keywords--],但是如果要给这些关键字词分开,并且加上标签样式,应该怎么做呢?下面是青青模板网整理的关于栏目字词显示列…

    帝国CMS 2024 年 7 月 20 日
    107
  • 帝国灵动标签调用广告列表

    帝国cms默认广告调用标签缺点 1、无法调用列表类型,只能单个调用 2、无法修改默认样式,默认样式100%被广告插件屏蔽 所以就算不管第一条,为了不被屏蔽也推荐用帝国CMS灵动标签…

    帝国CMS 2024 年 10 月 15 日
    79
  • 帝国CMS7.5版动态页新增缓存,让动态模式的网站速度更快

    帝国CMS7.5版动态页面新增支持缓存,让采用动态页面模式的网站访问速度更快,效率更高。 帝国CMS7.5版动态页面新增缓存功能: 1、动态首页新增缓存功能,动态页面模式下负载更好…

    2024 年 9 月 18 日
    91
  • 帝国CMS如何调用多值字段?

    <?php $daxiao=explode('||||||',$navinfor[daixiao360]); foreach($daxiao as $k=>$v) { …

    帝国CMS 2024 年 9 月 2 日
    77
  • 帝国CMS父栏目,终极栏目,非终极栏目的区别

    父栏目:就是通常所说的大栏目,每个父栏目下面可以包含若干个子栏目和终极栏目。父栏目下不可以直接增加信息(文章)。终极栏目:指没有子栏目的栏目,只有终极栏目下,才能增加信息(文章)。…

    2024 年 5 月 30 日
    120
  • 帝国CMS关于留言板模块可能会被灌水机盯上的公告

    近期接用户反馈,有帝国CMS用户的网站留言板被灌水机发布非法内容,所以特发此公告提醒所有用户:由于留言板功能可以发表内容:除了可以发表正常内容,也能发表广告、网址等非法内容,存在发…

    2024 年 12 月 3 日
    129
  • 帝国CMS8.0版后台登录后十八重安全验证

    第一重:系统验证采用随机密码认证,每次登录或退出都会产生新的随机密码,无规律可寻,并且认证采用数据库+COOKIE+文件+SESSION+登录文件内容验证五重认证,安全可靠。 第二…

    帝国CMS 2024 年 9 月 11 日
    86
  • 帝国CMS数据字典

    数据表名 解释 附加说明 信息表:每个模型都有以下10个表 phome_ecms_news_index 新闻系统模型-索引表 phome_ecms_news 新闻系统模型-主表 p…

    帝国CMS 2024 年 7 月 31 日
    92