最近用帝国CMS做一个网站,但是做到搜索页的时候发现并不能直接调用标签,在网上搜了很久找到了一个方法。

 
帝国本身的搜索框是不支持动态标签调用的
打开根目录/e/search/result/index.php 将下来代码全部粘贴覆盖。
  1. <?php   
  2. require('../../class/connect.php');  
  3. require('../../class/db_sql.php');  
  4. require('../../class/functions.php');  
  5. require('../../class/t_functions.php');  
  6. require('../../data/dbcache/class.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(emptyempty($getvar)) {   
  14.         $getfrom="history.go(-1)";  
  15. else {   
  16.         $getfrom="../../../search/";  
  17. }  
  18. //搜索结果   
  19. $searchid=(int)$_GET['searchid'];  
  20. if(emptyempty($searchid)) {   
  21.         printerror("SearchNotRecord",$getfrom,1);  
  22. }   
  23. $search_r=$empire->fetch1("select searchid,keyboard,result_num,orderby,myorder,tbname,tempid,andsql,trueclassid from {$dbtbpre}enewssearch where searchid='$searchid'");  
  24. if(emptyempty($search_r['searchid'])||InfoIsInTable($search_r[tbname])) {   
  25.         printerror("SearchNotRecord",$getfrom,1);  
  26. }   
  27. $page=(int)$_GET['page'];  
  28. $page=RepPIntvar($page);  
  29. $start=0;  
  30. $page_line=$public_r['search_pagenum'];//每页显示链接数   
  31. $line=$public_r['search_num'];//每页显示记录数   
  32. $offset=$page*$line;//总偏移量   
  33. $search="&searchid=".$searchid;  
  34. $myorder=$search_r[orderby];  
  35. if(emptyempty($search_r[myorder])) {   
  36.         $myorder.=" desc";  
  37. }   
  38. $add=stripSlashes($search_r['andsql']);  
  39. $num=$search_r[result_num];  
  40. $query="select * from {$dbtbpre}ecms_".$search_r[tbname].($add?' where '.substr($add,5):'');  
  41. $query.=" order by ".$myorder." limit $offset,$line";  
  42. $sql=$empire->query($query);  
  43. $listpage=page1($num,$line,$page_line,$start,$page,$search);  
  44. //取得模板   
  45. if($search_r['tempid']) {   
  46.         $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where tempid='".$search_r['tempid']."' limit 1");  
  47. elseif(emptyempty($class_r[$search_r[trueclassid]][searchtempid])) {   
  48.         $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where isdefault=1 limit 1");  
  49. else {   
  50.         $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");  
  51. }   
  52. $have_class=1;//页面支持标签   
  53. $tempr[temptext]=DtNewsBq('listsearch'.$search_r['tempid'],$tempr[temptext],0);//替换公共模板变量   
  54. $listtemp=$tempr[temptext];  
  55. if($public_r['searchtempvar']) { $listtemp=ReplaceTempvar($listtemp);  
  56. }   
  57. $search_r[keyboard]=ehtmlspecialchars($search_r[keyboard]);  
  58. $listtemp=str_replace("[!--show.page--]",$listpage,$listtemp);  
  59. $listtemp=str_replace("[!--keyboard--]",$search_r[keyboard],$listtemp);  
  60. $listtemp=str_replace("[!--ecms.num--]",$num,$listtemp);  
  61. $url="<a href='".ReturnSiteIndexUrl()."'>".$fun_r['index']."</a>&nbsp;>&nbsp;".$fun_r['adsearch'];  
  62. $pagetitle=$fun_r['adsearch']." ".$search_r[keyboard];  
  63. $listtemp=ReplaceSvars($listtemp,$url,0,$pagetitle,$pagetitle,$pagetitle,$add,0);  
  64. $rownum=$tempr[rownum];  
  65. if(emptyempty($rownum)) { $rownum=1;  
  66. }   
  67. $formatdate=$tempr[showdate];  
  68. $subnews=$tempr[subnews];  
  69. $subtitle=$tempr[subtitle];  
  70. $docode=$tempr[docode];  
  71. $modid=$tempr[modid];  
  72. $listvar=str_replace('[!--news.url--]',$public_r[newsurl],$tempr[listvar]);  
  73. //字段   
  74. $ret_r=ReturnReplaceListF($tempr[modid]);  
  75. //取得列表模板   
  76. $list_exp="[!--empirenews.listtemp--]";  
  77. $list_r=explode($list_exp,$listtemp);  
  78. $listtext=$list_r[1];  
  79. $no=$offset+1;  
  80. $changerow=1;  
  81. while($r=$empire->fetch($sql)) {   
  82.         //替换列表变量   
  83. $repvar=ReplaceListVars($no,$listvar,$subnews,$subtitle,$formatdate,$url,$have_class,$r,$ret_r,$docode);  
  84. $listtext=str_replace("<!--list.var".$changerow."-->",$repvar,$listtext);  
  85. $listtext=str_replace($search_r[keyboard],"<font color='red'>$search_r[keyboard]</font>",$listtext);  
  86. $changerow+=1;  
  87. //超过行数   
  88. if($changerow>$rownum) {  
  89. $changerow=1;  
  90. $string.=$listtext;  
  91. $listtext=$list_r[1];  
  92. $no++;  
  93. } db_close();  
  94. $empire=null;  
  95. //多余数据   
  96. if($changerow<=$rownum&&$listtext<>$list_r[1]) {  
  97.          $string.=$listtext;  
  98. }   
  99. $string=$list_r[0].$string.$list_r[2];  
  100. echo stripSlashes($string);  
  101. ?>  
这样就可以完美的调用各种标签了!