红穆笔记
首頁 › 程序筆記 › 帝國CMS搜索模板支持動態標籤調用
程序筆記 帝國cms

帝國CMS搜索模板支持動態標籤調用

帝国CMS搜索模板支持动态标签调用

打開/e/search/result/index.php文件查找:

require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../data/dbcache/class.php");
require("../../class/q_functions.php");
require "../".LoadLang("pub/fun.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");

接着查找:

//替換公共模板變量
$listtemp=$tempr[temptext];

在上面添加以下代碼:

//頁面支持標籤
$tempr[temptext]=DtNewsBq('list'.$tempid,$tempr[temptext],0);

你也可以直接複製下面的代碼直接替換/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=new mysqlquery();
$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("select searchid,keyboard,result_num,orderby,myorder,tbname,tempid,andsql,trueclassid from {$dbtbpre}enewssearch where searchid='$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.=" order by ".$myorder." limit $offset,$line";
$sql=$empire->query($query);$listpage=page1($num,$line,$page_line,$start,$page,$search);//取得模板 
if($search_r['tempid']) {
         $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where tempid='".$search_r['tempid']."' limit 1");
} elseif(empty($class_r[$search_r[trueclassid]][searchtempid])) { 
        $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where isdefault=1 limit 1");
} else {
         $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");
} 
$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="<a href='".ReturnSiteIndexUrl()."'>".$fun_r['index']."</a>&nbsp;>&nbsp;".$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],"<font color='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];
echo stripSlashes($string);
?>

微信赞赏

微信

支付宝赞赏

支付寶

✍️ 作者: 紅穆

網站管理員 · 感謝閱讀,更多精彩內容敬請關注

作者主頁 查看主頁 →

相關文章

帝国CMS数据库语句&amp;SQL语句格式

帝國CMS數據庫語句&amp;SQL語句格式 程序筆記 帝國cms

帝國CMS擴展SQL程序編寫介紹,帝國CMS數據庫語句&SQL語句格式基本範例:說明:下面例子都是以PHP文件放在系統根目錄爲基準。例1:連接MYSQL程序。(a.php)&lt;?php require('e/class/connect.php'); //引入數據庫配置文件和公共函數文件 requ…
👁 653
帝国CMS获取系统COOKIE变量函数getcvar()

帝國CMS獲取系統COOKIE變量函數getcvar() 程序筆記 帝國cms

取得系統COOKIE變量函數語法:getcvar($var,$ecms)說明:$var:爲變量名$ecms:0爲設置前臺COOKIE變量,1爲設置後臺COOKIE變量。此參數可省略,默認爲0。使用範例:getcvar('mlusername'),取得前臺登陸會員的用戶名getcvar('loginu…
👁 547
帝国CMS灵动标签调用字段大全

帝國CMS靈動標籤調用字段大全 程序筆記 帝國cms

將所有支持靈動標籤調用的字段收集歸類帝國CMS靈動標籤: [e:loop={欄目ID/專題ID,顯示條數,操作類型,只顯示有標題圖片,附加SQL條件,顯示排序}] 模板代碼內容 [/e:loop]調用時間:&lt;?=date('m-d',$bqr[newstime])?&gt; &lt;?=dat…
👁 4098

推薦閱讀

pbootcms调用指定栏目下面的子栏目

pbootcms調用指定欄目下面的子欄目 程序筆記 PbootCms

指定欄目標籤適用範圍:全站任意地方均可使用標籤作用:用於調導航菜單欄目列表,對應後臺的“基礎內容&gt;內容欄目”1、指定欄目列表{pboot:sort scode=*} &lt;a href= &quot;[sort:link]&quot;&gt;[sort:name]&lt;/a&gt; {/p…
👁 619
php查询数据库时,防止SQL注入

php查詢數據庫時,防止SQL注入 語言筆記 PHP

PHP中防止SQL注入的方式主要有兩種:使用預處理語句預處理語句是將查詢語句提前準備好,然後再將參數傳遞到查詢語句中,這樣可以防止SQL注入攻擊。在PHP中,我們可以使用PDO或mysqli擴展來實現預處理語句。以下是使用mysqli實現預處理語句的示例代碼:// 數據庫連接 $host = 'lo…
👁 436
海洋cms 如何让ifream框架内的内容高宽撑开?

海洋cms 如何讓ifream框架內的內容高寬撐開? 踩坑總結

以通過以下方式實現前端讓iframe框架內的內容高寬撐開:在iframe標籤中設置scrolling="no"和frameborder="0",禁用滾動條和邊框。在iframe標籤後添加一個&lt;div&gt;,並給該&lt;div&gt;設置樣式position: relative; width…
👁 442
(PC+WAP)绿色环保设备pbootcms企业网站模板 环保企业网站源码下载 0088

(PC+WAP)綠色環保設備pbootcms企業網站模板 環保企業網站源碼下載 0088 實用收藏 pbootcms模板

這套PbootCMS模板是專爲環保設備企業打造的綠色風格公司官網,支持PC與移動端。設計風格清新自然,能夠很好地展示污水處理、空氣淨化等環保設備產品。有助於環保公司在線上樹立專業形象,拓展業務合作渠道。模板展示 安裝說明 網站後臺:/admin.php 賬號:admin 密碼:admin 解壓密碼:…
👁 347
(PC+WAP)pbootcms绿色环保通用企业网站模板 建筑通用行业网站源码下载 0548

(PC+WAP)pbootcms綠色環保通用企業網站模板 建築通用行業網站源碼下載 0548 實用收藏 pbootcms模板

一款綠色環保風格的PbootCMS通用企業網站模板,適用於建築、工程及環保行業,支持PC和手機端。設計風格簡約大氣,符合建築環保類企業的品牌調性。模板內置了完善的企業展示模塊,幫助企業快速上線品牌形象網站,有效提升客戶信任度。模板展示 安裝說明 網站後臺:/admin.php 賬號:admin 密碼…
👁 287