帝國(guó)cms默認(rèn)的[!--other.link--]標(biāo)簽調(diào)用相關(guān)鏈接時(shí),如果沒有相關(guān)鏈接的話,則會(huì)顯示“暫無(wú)相關(guān)鏈接”。對(duì)于一些采集站或其他需要增加內(nèi)鏈的網(wǎng)站來說,此時(shí)最好能調(diào)用本欄目的其它一些信息填充進(jìn)來。這里分享一個(gè)自己用的函數(shù),實(shí)現(xiàn)這個(gè)功能。
當(dāng)信息有相關(guān)信息時(shí),調(diào)用相關(guān)信息,如果沒有,則調(diào)用同欄目、當(dāng)前信息前后100個(gè)id之內(nèi)的信息中發(fā)布時(shí)間最靠近的,100可以設(shè)置成參數(shù)。將此函數(shù)放進(jìn) userfun.php 文件中,
function dp_GetKeyboard($num=100){
global $empire,$public_r,$class_r,$fun_r,$dbtbpre,$class_r,$navinfor;
$keyid=$navinfor['keyid'];
$classid=$navinfor['classid'];
$id=$navinfor['id'];
$link_num=$class_r[$classid]['link_num'];
if(!$link_num){
return $fun_r['NotLinkNews'];
}
$tr=$empire->fetch1("select otherlinktemp,otherlinktempsub,otherlinktempdate from ".GetTemptb("enewspubtemp")." limit 1");
$temp_r=explode("[!--empirenews.listtemp--]",$tr[otherlinktemp]);
if($keyid){
$add="id in (".$keyid.")";
}else{
$e=$id+$num;
$s=$id-$num;
$add=" classid=".$classid." and id>".$s." and id<".$e;
}
$key_sql=$empire->query("select id,newstime,title,isurl,titleurl,classid,titlepic from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$add." order by newstime desc limit $link_num");
while($link_r=$empire->fetch($key_sql)){
if($link_r['id']==$id){
continue;
}
$keyboardtext.=RepOtherTemp($temp_r[1],$link_r,$tr);
}
if(empty($keyboardtext)){
return $fun_r['NotLinkNews'];
}
$keyboardtext=$temp_r[0].$keyboardtext.$temp_r[2];
return $keyboardtext;
}
在模板中調(diào)用方法:<!--?=dp_getkeyboard(200)?-->
這個(gè)函數(shù)滿足我一個(gè)小站的功能,對(duì)于其它網(wǎng)站來說,補(bǔ)充調(diào)用信息可能比較簡(jiǎn)陋,可以自行修改。
此文由 網(wǎng)站目錄_網(wǎng)站網(wǎng)址收錄與提交入口 編輯,未經(jīng)允許不得轉(zhuǎn)載?。?!--首頁(yè) > 站長(zhǎng)文章 > 帝國(guó)cms » 帝國(guó)CMS沒有相關(guān)信息時(shí)調(diào)用其它信息教程-->