最完美解决搜索模板调用动态标签支持多模板的问题

让7.0的搜索模板也支持动态标签
http://bbs.phome.net/ShowThread/?threadid=281670&forumid=13

完美解决关于搜索模板调用动态标签支持多模板的问题
http://bbs.phome.net/ShowThread?threadid=314384&forumid=13

由于在做网站已经删除了原来的模板,所以不存在id号为2,3的列表列表模板,而搜索模板id号为2,3,所以不存在冲突,现有同志反映还有冲突,经查是与栏目列表动态模板冲突,再次修改代码,应该完美了。

  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(empty($getvar)) {
  14.         $getfrom="history.go(-1)";
  15. } else {
  16.         $getfrom="../../../search/";
  17. }
  18. //搜索结果
  19. $searchid=(int)$_GET[‘searchid’];
  20. if(empty($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(empty($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(empty($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(empty($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> > ".$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(empty($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. ?>

复制代码

将此文件放到e/search/result/index.php目录覆盖就OK了

上一篇:帝国CMS系统限制的搜索关键字只能在 2~20 个字符之间的解决方法
下一篇:帝国CMS更改完搜索列表模板不生效的解决方法

© 版权声明
THE END
帝国cms教程
点赞7 分享
相关推荐
评论 抢沙发

请登录后发表评论

    暂无评论内容