精華 帝國PHP系統(tǒng)內(nèi)容頁暫無相關(guān)內(nèi)容,就調(diào)用當(dāng)前欄目其它信息
<p>帝國php系統(tǒng)默認(rèn)的相關(guān)鏈接標(biāo)簽[!--other.link--]在調(diào)用相關(guān)鏈接時,如果沒有其它相關(guān)鏈接的話,會顯示“暫無相關(guān)鏈接”。對于需要增加內(nèi)鏈的網(wǎng)站來說,此時最好能調(diào)用本欄目的其它一些信息填充進(jìn)來。這里介紹一個通過增加函數(shù)來實現(xiàn)這個功能的方法,樣式還是系統(tǒng)原來自帶的樣式。</p>
找到/e/class/userfun.php 將此函數(shù)放進(jìn)此文件中,代碼如下:
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;
}
當(dāng)信息有相關(guān)信息時,調(diào)用相關(guān)信息,如果沒有調(diào)用同欄目、當(dāng)前信息前后100個id之內(nèi)的信息中發(fā)布時間最靠近的文章。
函數(shù)在模板中調(diào)用方法:<?=dp_GetKeyboard(200)?>,放在相關(guān)內(nèi)容的地方調(diào)用