解决帝国CMS搜索页面模板不支持灵动标签和万能标签的方法
时间:2024年04月02日
/来源:网络
/编辑:佚名
1,打开 /e/search/result/index.php 文件
查找
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");
复制代码
2,再查找
//替换公共模板变量
$listtemp=$tempr[temptext];
在上面添加如下代码
//页面支持标签
$tempr[temptext]=DtNewsBq('list'.$tempid,$tempr[temptext],0);
修改完成,这样就可以在搜索模板中灵活使用帝国cms强大的灵动和万能标签了
下边的代码直接覆盖掉/e/search/result/index.php文件就可以。
复制代码
<?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> > ".$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);
?>
复制代码
查找
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");
复制代码
2,再查找
//替换公共模板变量
$listtemp=$tempr[temptext];
在上面添加如下代码
//页面支持标签
$tempr[temptext]=DtNewsBq('list'.$tempid,$tempr[temptext],0);
修改完成,这样就可以在搜索模板中灵活使用帝国cms强大的灵动和万能标签了
下边的代码直接覆盖掉/e/search/result/index.php文件就可以。
复制代码
<?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> > ".$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);
?>
复制代码
新闻资讯 更多
- 【帝国cms教程】帝国CMS模板变量$GLOBALS[navclassid]用法分析04-03
- 【帝国cms教程】鲜为人知帝国CMS内容页调用上一篇和下一篇的精华方法汇总04-03
- 【帝国cms教程】怎么快速找出帝国CMS数据库配置文件路径及迁移网站后修改技巧!04-03
- 【帝国cms教程】帝国CMS模板$GLOBALS[navclassid]用法详解04-03
- 【帝国cms教程】帝国cms 7.5版列表页分页样式修改笔记04-02
- 【帝国cms教程】解决帝国CMS搜索页面模板不支持灵动标签和万能标签的方法04-02
- 【帝国cms教程】帝国CMS只备份栏目和模板的方法04-02
- 【帝国cms教程】帝国CMS怎样删除清空数据库记录?04-02
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 9帝国cms后台登录出现”您还未登录”怎么解决?
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法