如何让帝国CMS7.2搜索模板支持动态标签调用

  帝国cms站内搜索一般不支持动态标签调用,如果要调用如何实现呢?修改两个地方就可以实现了。打开 /e/search/result/index.php 文件,找到(文件改了,不会调用也是徒劳!看看这个帝国cms搜索关键字调用标签(showsearch)怎么用

require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../data/dbcache/class.php");
require("../../class/q_functions.php");
require "../".LoadLang("pub/fun.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");

接着查找:

//替换公共模板变量
$listtemp=$tempr[temptext];

在上面添加以下代码:

//页面支持标签
$tempr[temptext]=DtNewsBq('list'.$tempid,$tempr[temptext],0);

  ytkah早就猜到你不想去一行行找了,哈哈,直接提供修改后的整个代码如下

<?php
require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../data/dbcache/class.php");
require('../../class/functions.php');
require('../../class/t_functions.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'.$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($string);
?>

 

时间: 2024-08-07 19:44:09

如何让帝国CMS7.2搜索模板支持动态标签调用的相关文章

帝国cms7.2搜索页面支持灵动标签调用和多个模板搜索

修改esearchresult文件代码如下: <?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(

帝国CMS7.2版多终端访问模板设置使用功能图文教程

随着PC互联网与移动互联网的不断融合.以及各类移动访问终端增加,网站移动互联越来越重要了,所以帝国CMS7.2版本在原来版本的多访问终端功能基础上,做出更多的改进,让网站多种移动访问端制作更加方便.下面我们来讲解帝国CMS7.2版本的"多终端访问功能"使用: 新增网站访问端步骤: 一.设置所有访问端统一的访问地址: 二.新增访问端使用的模板组: 三.新建访问端目录,并复制一份帝国CMS程序文件进去: 四.给新增的访问端目录绑定个二级域名: 五.到主访问端后台新增"网站访问端&

帝国CMS7.2版手机模板灵动标签函数使用

在移动互联时代,帝国CMS7.2版本除了增加完善多终端模板组访问实现,还升级了移动互联另一个最早方案:WAP手机访问,在原来WAP系统功能的基础上进行升级,使WAP访问更适应智能手机等终端设备. 帝国CMS7.2的WAP更新功能如下: 1.新增了针对WAP信息调用的"灵动标签函数",使WAP模板调用信息更简单,不用写sql查询执行代码,制作WAP模板更方便. WAP的"灵动标签函数"参数和语法和灵动标签一样,具体语法为如下: <?php $wapsql=ewa

帝国cms7.2版本实现发布时间为:几小时前、几天前等格式的方法

帝国cms7.2怎样实现时间为:几小时前.几天前等格式 将以下代码放到:userfun.php <?ph ?>之间 function user_time($tm,$num) { if($num==1){    $tm =  strtotime($tm); }     $cur_tm = time(); $dif = $cur_tm-$tm;    $pds = array('秒','分钟','小时','天','周','个月','年');    $lngh = array(1,60,3600,8

ThinkPHP多语言支持与多模板支持概述_php实例

本文以实例形式简述了ThinkPHP的多语言支持与多模板支持.是ThinkPHP中非常重要的技巧,分享给大家供大家参考.具体如下: 一.ThinkPHP多语言支持: config.php配置文件中添加: //多语言支持设置 'LANG_SWITCH_ON'=>true, 'DEFAULT_LANG'=>'zh-cn', 'LANG_AUTO_DETECT'=>true, 'LANG_LIST'=>'en-us,zh-cn,zh-tw', Home/Lang/文件夹下建立三个文件夹,

ThinkPHP2.1 增加PHPCMS模板引擎,支持PC标签(get,json)

本人经常使用PHPCMS模板引擎. 用ThinkPHP2.1 自带的,感觉不爽,花点时间增加了个PHPCMS模板引擎 BY 夜色紫宸風 功能:PHPCMS模板解析引擎,支持PC标签(get,json),也可以使用ThinkPHP2.1的模板数据,都支持 TemplatePhpcms.class.php 把这个文件放到 ThinkPHP\Lib\Think\Util\Template 文件夹中 <?php /** +-----------------------------------------

帝国cms7.0首页读取TAGS方法

帝国cms 7.0之前版本首页调用tag的方法是: [e:loop={0,1,13,1} <?             $a="$bqr[infotags]";             $str=str_replace(',', ',', $a);             $tag='';             $t= explode(",", $str);                                 for($i=0;$i<cou

帝国cms常用标签调用方法总结

幻灯片: 1.显示表最新的头条信息(数字13代表头条,数字3代表最新) [phomeflashpic]0,4,280,255,0,0,13,3[/phomeflashpic] 2.显示栏目最新的推荐信息并且显示标题(数字2代表栏目推荐,最后的数字0代表栏目最新) [phomeflashpic]7,4,280,255,1,40,2,0[/phomeflashpic] 标题+简介(灵动标签的调用方法) [e:loop={2,1,0,0}]  <h1><a href="<?=$

百度开始支持支持canonical标签 通过算法识别规范网页

        站长网(www.admin5.com/)1月8日消息,今日百度站长平台发布公告,宣布百度开始支持Canonical标签.为了避免重复内容的收录,百度会通过算法对网页内容及链接进行识别,对内容完全相同或者高度相似的网页,会计算出一个系统认为规范的网页结果建立索引并供用户查询.站长可以通过将 <link> 元素和 rel="canonical" 属性添加到该网页非规范版本的<head> 部分,为搜索引擎指定规范网页. 公告如下: 一.Canonica