帝国cms搜索模板支持调用动态标签方法_帝国Cms教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

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

查看更多 帝国cms教程  帝国cms模板

来源:模板无忧//所属分类:帝国Cms教程/更新时间:2020-06-08
相关帝国Cms教程