帝国搜索页面支持调用动态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

相关推荐

  • 帝国灵动标签调用文章排行榜

    目前所用的到方法是系统自带的$bqno,顺序标签判断来进行样式的添加可定义一行一个样式。 可根据自己的使用情况进行修改,调用方式如下: [e:loop={1,10,0,0}]&lt…

    帝国CMS 2024 年 5 月 22 日
    235
  • 帝国数据表phome_ecms_news_data_1字段解释(新闻系统模型-副表1)

    字段名 字段类型 解释 id int(10) unsigned 信息ID classid smallint(5) unsigned 栏目ID keyid varchar(255) …

    帝国CMS 2024 年 10 月 10 日
    124
  • 帝国灵动标签调用广告列表

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

    帝国CMS 2024 年 10 月 15 日
    87
  • 帝国CMS内容列表如何实现实时显示点击数?

    (图片来源网络,侵删) 我们需要在数据库中添加一个字段来存储点击数,假设我们的项目表名为project,我们可以在数据库管理工具中为该表添加一个名为click_count的字段,数…

    2024 年 4 月 17 日
    205
  • 帝国CMS验证码不显示?可能是哪里的问题?

    帝国cms验证码打叉不显示解决方法一般是utf8版本的帝国cms会遇到了,原因是你用普通记事本修改了 e/config/config.php (6.6版本的帝国是 e/class/…

    帝国CMS 2024 年 8 月 31 日
    79
  • 帝国CMS常用的变量

    1、系统模板所在的位置: 采集字段模板 e/data/html/cjhtml.txt 前台字段表单模板 e/data/html/qfhtml.txt 后台字段表单模板 e/data…

    帝国CMS 2024 年 5 月 14 日
    247
  • 帝国后台恢复数据后栏目不显示怎么办?

    操作方法如下: 首先登录进入后台,点击后台导航下面的  数据更新  右边一排更新数据缓存 依次点击即可。把站点内的缓存更新一遍就好了。 更新的项目有:更新数据库缓存、恢复栏目目录、…

    帝国CMS 2024 年 5 月 12 日
    136
  • 帝国调用自定义页面的技巧

    我们做单页(比如“公司介绍”、“联系我们”等页面)时一般采用自定义页面来做,而调用出自定义页面导航可以用标签SQL调用。如下: 例子1:调用自定义页面分类ID=1的页面导航 [e:…

    帝国CMS 2024 年 8 月 23 日
    96
  • 帝国CMS列表页调用文章tag的2种方法

    列表页调用tag的方法有两种,一种是切割副表的infotags字段,第二种种是从phome_enewstagsdata表中提取。如果采用tagid或tag静态化,则推荐使用第二种方…

    帝国CMS 2024 年 8 月 25 日
    103
  • 帝国CMS父栏目,终极栏目,非终极栏目的区别

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

    2024 年 5 月 30 日
    125