帝國CMS怎么用TAG調用相關文章
用tag調用相關文章的方法在帝國官方論壇上有人發過方法,但所使用的函數效率太低而且無法制定參數,不好用。現在使用的也是利用tag調用相關文章,非常好用。
一、自定義函數
自定義函數user_OtherLink ,將此函數放入 eclassuserfun.php 文件中。
//根據tag獲取相關信息
function user_OtherLink($num,$classid=0,$mid=0){
global $dbtbpre,$empire,$navinfor,$class_r;
if(empty($navinfor['infotags'])){
return '暫無相關信息';
}
if($mid&&$classid&&$class_r[$classid]['modid']!=$mid){
return '暫無相關信息';
}
$tr=$empire->fetch1("select otherlinktemp,otherlinktempsub,otherlinktempdate from ".GetTemptb("enewspubtemp")." limit 1");
$temp_r=explode("[!--empirenews.listtemp--]",$tr['otherlinktemp']);
$str='';
$tagsql=$empire->query("select * from {$dbtbpre}enewstagsdata where id='$navinfor[id]' and classid='$navinfor[classid]'");
$i=0;
$isprint=array();
while($tagr=$empire->fetch($tagsql)){
if($i>=$num){
break;
}
$gsql=$empire->query("select * from {$dbtbpre}enewstagsdata where tagid='$tagr[tagid]'");
while($gr=$empire->fetch($gsql)){
$myprint='id'.$gr['id'].'class'.$gr['classid'];
if(array_search($myprint,$isprint)!==false){
continue;
}
$isprint[]=$myprint;
if($classid&&$classid!=$gr['classid']){
continue;
}
if($mid&&$mid!=$gr['mid']){
continue;
}
if($gr['id']==$navinfor['id']&&$gr['classid']==$navinfor['classid']){
continue;
}
$tbname=$class_r[$gr['classid']]['tbname'];
if(!$tbname||InfoIsInTable($tbname)){
continue;
}
$r=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id='$gr[id]' limit 1");
if(!$r['id']){
continue;
}
$str.=RepOtherTemp($temp_r[1],$r,$tr);
$i+=1;
if($i>=$num){
break;
}
}
}
$keyboardtext=$temp_r[0].$str.$temp_r[2];
if($str){
return $keyboardtext;
}else{
return '暫無相關信息';
}
}
二、 使用方法:
函數說明:user_OtherLink(調用條數,指定欄目id,指定模型id) ;
相關文章模板采用的是公共模板里的相關信息模板。
調用示例:
<?=user_OtherLink(10,0,1)?>
聲明:本文內容由互聯網用戶自發貢獻,該文觀點僅代表作者本人。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如發現本站有涉嫌抄襲侵權/違法違規的內容, 請發送郵件至201542412@QQ.com舉報,一經查實,本站將立刻刪除。
相關推薦
-
帝國cms靈動標簽調用相關文章,SQL語句指定關鍵詞調用文章
帝國cms靈動標簽調用相關文章,SQL語句指定關鍵詞調用,帝國cms根據指定關鍵詞調取相關文章的方式有下面幾種
-
帝國CMS內容頁相關文章調用
標題包含關鍵字①、比較粗糙的匹配,可能不太精確:titllik'%$navinfor[kyboard]%'②、精確的匹配,比較消耗資源:titlrgxp'(^|,)$navinfor[kyboard]($|,)'...
-
帝國CMS沒有相關文章,則調用最新文章的方法代碼
帝國CMS文章內容頁可以通過!--othr.link--調用相關鏈接,這個標簽在后臺編輯內容頁模板時,通過模板變量說明可以找到。使用該標簽可以在后臺系統設置中設置相關鏈接依據(標題
-
帝國CMS內容頁根據關鍵詞來調用相關文章
帝國cms內容頁根據關鍵詞來調用相關內容,如果沒有相關內容則隨機獲得文章代碼。?phpif($navinfor){$cky=xplod(,,$navinfor);$count=count
-
帝國CMS靈動標簽調用相關文章的方法
標題包含關鍵字①、比較粗糙的匹配,可能不太精確:titllik%$navinfor%②、精確的匹配,比較消耗資源:titlrgxp(^|,)$navinfor($|,)&















