帝国CMS默许动态模板都不支撑帝国cms封装标签调用,这儿供给了让动态模板支撑帝国cms封装标签调用的办法。
办法:仿制以下代码到e/search/result/index.php
<?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"); $editor=1; eCheckCloseMods('search');//封闭模块 $link=db_connect(); $empire=newmysqlquery(); $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("selectsearchid,keyboard,result_num,orderby,myorder,tbname,tempid,andsql,trueclassidfrom{$dbtbpre}enewssearchwheresearchid='$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.="orderby".$myorder."limit$offset,$line"; $sql=$empire->query($query); $listpage=page1($num,$line,$page_line,$start,$page,$search); //获得模板 if($search_r['tempid']){ $tempr=$empire->fetch1("selecttemptext,subnews,listvar,rownum,showdate,modid,subtitle,docodefrom".GetTemptb("enewssearchtemp")."wheretempid='".$search_r['tempid']."'limit1"); }elseif(empty($class_r[$search_r[trueclassid]][searchtempid])){ $tempr=$empire->fetch1("selecttemptext,subnews,listvar,rownum,showdate,modid,subtitle,docodefrom".GetTemptb("enewssearchtemp")."whereisdefault=1limit1"); }else{ $tempr=$empire->fetch1("selecttemptext,subnews,listvar,rownum,showdate,modid,subtitle,docodefrom".GetTemptb("enewssearchtemp")."wheretempid='".$class_r[$search_r[trueclassid]][searchtempid]."'limit1"); } $have_class=1;//页面支撑标签 $tempr[temptext]=DtNewsBq('listsearch'.$search_r['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="<ahref='".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); $listtext=str_replace($search_r[keyboard],"<fontcolor='red'>$search_r[keyboard]</font>",$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]; echostripSlashes($string); ?>
声明:有的资源均来自网络转载,版权归原作者所有,如有侵犯到您的权益 请联系邮箱:123456@qq.com 我们将配合处理!
原文地址:帝国cms二次开发搜索模板支持调用动态标签方法发布于2022-06-09 07:43:50