帝国CMS默认搜索页面模板不支持灵动标签和万能标签的解决方法

  • A+
所属分类:帝国cms教程

解决帝国CMS默认搜索页面模板不支持灵动标签和万能标签的方法

帝国默认搜索模板 不支持<?=$public_r[sitename]?> 帝国搜索模板乱码

1,打开 /e/search/result/index.php 文件

查找

  1. require("../../class/connect.php");
  2. require("../../class/db_sql.php");
  3. require("../../data/dbcache/class.php");
  4. require("../../class/q_functions.php");
  5. require "../".LoadLang("pub/fun.php");

修改为:

  1. require('../../class/connect.php');
  2. require('../../class/db_sql.php');
  3. require('../../class/functions.php');
  4. require('../../class/t_functions.php');
  5. require('../../data/dbcache/class.php');
  6. require "../".LoadLang("pub/fun.php");

2,再查找

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

在上面添加如下代码

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

修改完成,这样就可以在搜索模板中灵活使用帝国cms强大的灵动和万能标签了

下边的代码直接覆盖掉/e/search/result/index.php文件就可以。

  1. <?php
  2. require("../../class/connect.php");
  3. require("../../class/db_sql.php");
  4. require("../../data/dbcache/class.php");
  5. require('../../class/functions.php');
  6. require('../../class/t_functions.php');
  7. require "../".LoadLang("pub/fun.php");
  8. $editor=1;
  9. eCheckCloseMods('search');//关闭模块
  10. $link=db_connect();
  11. $empire=new mysqlquery();
  12. $getvar=$_GET['getvar'];
  13. if(empty($getvar))
  14. {
  15. $getfrom="history.go(-1)";
  16. }
  17. else
  18. {
  19. $getfrom="../../../search/";
  20. }
  21. //搜索结果
  22. $searchid=(int)$_GET['searchid'];
  23. if(empty($searchid))
  24. {
  25. printerror("SearchNotRecord",$getfrom,1);
  26. }
  27. $search_r=$empire->fetch1("select searchid,keyboard,result_num,orderby,myorder,tbname,tempid,andsql,trueclassid from {$dbtbpre}enewssearch where searchid='$searchid'");
  28. if(empty($search_r['searchid'])||InfoIsInTable($search_r[tbname]))
  29. {
  30. printerror("SearchNotRecord",$getfrom,1);
  31. }
  32. $page=(int)$_GET['page'];
  33. $page=RepPIntvar($page);
  34. $start=0;
  35. $page_line=$public_r['search_pagenum'];//每页显示链接数
  36. $line=$public_r['search_num'];//每页显示记录数
  37. $offset=$page*$line;//总偏移量
  38. $search="&searchid=".$searchid;
  39. $myorder=$search_r[orderby];
  40. if(empty($search_r[myorder]))
  41. {
  42. $myorder.=" desc";
  43. }
  44. $add=stripSlashes($search_r['andsql']);
  45. $num=$search_r[result_num];
  46. $query="select * from {$dbtbpre}ecms_".$search_r[tbname].($add?' where '.substr($add,5):'');
  47. $query.=" order by ".$myorder." limit $offset,$line";
  48. $sql=$empire->query($query);
  49. $listpage=page1($num,$line,$page_line,$start,$page,$search);
  50. //取得模板
  51. if($search_r['tempid'])
  52. {
  53. $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where tempid='".$search_r['tempid']."' limit 1");
  54. }
  55. elseif(empty($class_r[$search_r[trueclassid]][searchtempid]))
  56. {
  57. $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where isdefault=1 limit 1");
  58. }
  59. else
  60. {
  61. $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");
  62. }
  63. $have_class=1;
  64. //页面支持标签
  65. $tempr[temptext]=DtNewsBq('list'.$tempid,$tempr[temptext],0);
  66. //替换公共模板变量
  67. $listtemp=$tempr[temptext];
  68. if($public_r['searchtempvar'])
  69. {
  70. $listtemp=ReplaceTempvar($listtemp);
  71. }
  72. $search_r[keyboard]=ehtmlspecialchars($search_r[keyboard]);
  73. $listtemp=str_replace("[!--show.page--]",$listpage,$listtemp);
  74. $listtemp=str_replace("[!--keyboard--]",$search_r[keyboard],$listtemp);
  75. $listtemp=str_replace("[!--ecms.num--]",$num,$listtemp);
  76. $url="<a href='".ReturnSiteIndexUrl()."'>".$fun_r['index']."</a>&nbsp;>&nbsp;".$fun_r['adsearch'];
  77. $pagetitle=$fun_r['adsearch']." ".$search_r[keyboard];
  78. $listtemp=ReplaceSvars($listtemp,$url,0,$pagetitle,$pagetitle,$pagetitle,$add,0);
  79. $rownum=$tempr[rownum];
  80. if(empty($rownum))
  81. {
  82. $rownum=1;
  83. }
  84. $formatdate=$tempr[showdate];
  85. $subnews=$tempr[subnews];
  86. $subtitle=$tempr[subtitle];
  87. $docode=$tempr[docode];
  88. $modid=$tempr[modid];
  89. $listvar=str_replace('[!--news.url--]',$public_r[newsurl],$tempr[listvar]);
  90. //字段
  91. $ret_r=ReturnReplaceListF($tempr[modid]);
  92. //取得列表模板
  93. $list_exp="[!--empirenews.listtemp--]";
  94. $list_r=explode($list_exp,$listtemp);
  95. $listtext=$list_r[1];
  96. $no=$offset+1;
  97. $changerow=1;
  98. while($r=$empire->fetch($sql))
  99. {
  100. //替换列表变量
  101. $repvar=ReplaceListVars($no,$listvar,$subnews,$subtitle,$formatdate,$url,$have_class,$r,$ret_r,$docode);
  102. $listtext=str_replace("<!--list.var".$changerow."-->",$repvar,$listtext);
  103. $changerow+=1;
  104. //超过行数
  105. if($changerow>$rownum)
  106. {
  107. $changerow=1;
  108. $string.=$listtext;
  109. $listtext=$list_r[1];
  110. }
  111. $no++;
  112. }
  113. db_close();
  114. $empire=null;
  115. //多余数据
  116. if($changerow<=$rownum&&$listtext<>$list_r[1])
  117. {
  118. $string.=$listtext;
  119. }
  120. $string=$list_r[0].$string.$list_r[2];
  121. echo stripSlashes($string);
  122. ?>

 

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: