苏打夹心 發表於 2023-6-29 00:00:00

帝国cms相关链接无内容时调用当前栏目最热信息的方法

<p>
帝国cms相关链接,这里以帝国cms 7.0为例具体代码 在/e/class/functions.php</p>
<p>
$keyboardtext='&lt;?=GetKeyboard($ecms_gr,$ecms_gr,$ecms_gr,$ecms_gr,$class_r[$ecms_gr])?&gt;';可以看到相关链接的信息是通过GetKeyboard得到,找到 GetKeyboard修改一下就可以了,也是在/e/class/functions.php<br>
 <br>
 </p>
<div>

<p>
代码如下:</p>
</div>
<div id="phpcode5">
<br>
//取得相关链接<br>
function GetKeyboard($keyboard,$keyid,$classid,$id,$link_num){<br>
global $empire,$public_r,$class_r,$fun_r,$dbtbpre;<br>
if($keyid&amp;&amp;$link_num)<br>
{<br>
$add="id in (".$keyid.")";<br>
$tr=$empire-&gt;fetch1("select otherlinktemp,otherlinktempsub,otherlinktempdate from ".GetTemptb("enewspubtemp")." limit 1");//取得相关链接模板<br>
$temp_r=explode("[!--empirenews.listtemp--]",$tr);<br>
$key_sql=$empire-&gt;query("select id,newstime,title,isurl,titleurl,classid,titlepic,lastvolume from {$dbtbpre}ecms_".$class_r[$classid]." where ".$add." order by newstime desc limit $link_num");<br>
while($link_r=$empire-&gt;fetch($key_sql))<br>
{<br>
//=========================================================2012-12-25 4usky.com<br>
$text=RepOtherTemp($temp_r,$link_r,$tr);<br>
$text=str_replace('[!--no--]',$i,$text);<br>
$text=str_replace('[!--state--]',$link_r,$text);<br>
$text=str_replace('[!--lastvolume--]',$link_r,$text);<br>
$keyboardtext.=$text;<br>
//$keyboardtext.=RepOtherTemp($temp_r,$link_r,$tr);<br>
}<br><br>
$keyboardtext=$temp_r.$keyboardtext.$temp_r;<br>
}<br>
else<br>
{<br>
//-------------生成的时候加载一次keyid zhuxianfei.com 2013/5/17 星期五<br>
$keyid=GetKeyid($keyboard,$classid,0,$link_num);<br>
if($keyid)<br>
{<br>
$fsql=$empire-&gt;query("update {$dbtbpre}ecms_".$class_r[$classid]."_data_1 set keyid='$keyid' where id='$id'");<br>
$add="id in (".$keyid.")";<br>
$tr=$empire-&gt;fetch1("select otherlinktemp,otherlinktempsub,otherlinktempdate from ".GetTemptb("enewspubtemp")." limit 1");//取得相关链接模板<br>
$temp_r=explode("[!--empirenews.listtemp--]",$tr);<br>
$key_sql=$empire-&gt;query("select id,newstime,title,isurl,titleurl,classid,titlepic,lastvolume from {$dbtbpre}ecms_".$class_r[$classid]." where ".$add." order by newstime desc limit $link_num");<br>
while($link_r=$empire-&gt;fetch($key_sql))<br>
{<br>
//=========================================================2012-12-25 4usky.com<br>
$text=RepOtherTemp($temp_r,$link_r,$tr);<br>
$text=str_replace('[!--no--]',$i,$text);<br>
$text=str_replace('[!--state--]',$link_r,$text);<br>
$text=str_replace('[!--lastvolume--]',$link_r,$text);<br>
$keyboardtext.=$text;<br>
//$keyboardtext.=RepOtherTemp($temp_r,$link_r,$tr);<br>
}<br><br>
$keyboardtext=$temp_r.$keyboardtext.$temp_r;<br>
}<br>
else //没有关键字的时候读取人气最高的几条信息 2013/5/17 星期五 zhuxianfei.com<br>
{<br>
$add="";<br>
$tr=$empire-&gt;fetch1("select otherlinktemp,otherlinktempsub,otherlinktempdate from ".GetTemptb("enewspubtemp")." limit 1");//取得相关链接模板<br>
$temp_r=explode("[!--empirenews.listtemp--]",$tr);<br>
$key_sql=$empire-&gt;query("select id,newstime,title,isurl,titleurl,classid,titlepic,lastvolume from {$dbtbpre}ecms_".$class_r[$classid]." where order by onclick desc limit $link_num");<br>
while($link_r=$empire-&gt;fetch($key_sql))<br>
{<br>
//=========================================================2012-12-25 4usky.com<br>
$text=RepOtherTemp($temp_r,$link_r,$tr);<br>
$text=str_replace('[!--no--]',$i,$text);<br>
$text=str_replace('[!--state--]',$link_r,$text);<br>
$text=str_replace('[!--lastvolume--]',$link_r,$text);<br>
$keyboardtext.=$text;<br>
//$keyboardtext.=RepOtherTemp($temp_r,$link_r,$tr);<br>
}<br><br>
$keyboardtext=$temp_r.$keyboardtext.$temp_r;<br>
}<br>
//----------------------------------------------------------------------------------------------<br>
//$keyboardtext=$fun_r['NotLinkNews'];<br>
}<br>
return $keyboardtext;<br>
}</div>
<p>
 </p>
<p>
原来的官方代码</p>
<p>
在没有关键字的时候直接就给出</p>
<p>
$keyboardtext=$fun_r['NotLinkNews'];<br>
这显示无相关信息</p>
<p>
我做了一个无keyid的时候再去获取一次keyid,</p>
<p>
$keyid=GetKeyid($keyboard,$classid,0,$link_num);<br>
确实没有关键字的时候读取人气最高的几条信息</p>
<p>
$key_sql=$empire-&gt;query("select id,newstime,title,isurl,titleurl,classid,titlepic,lastvolume from {$dbtbpre}ecms_".$class_r[$classid]." where  order by onclick desc limit $link_num");</p>
頁: [1]
查看完整版本: 帝国cms相关链接无内容时调用当前栏目最热信息的方法