首页建站帝国CMS教程 帝国cms相关链接无内容时调用当前栏目最热信息的方法

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

这篇文章主要为大家分享下帝国cms相关链接无内容时调用当前栏目最热信息的方法,需要的朋友可以参考下帝国cms相关链接,这里以帝国cms 7.0为例具体代码 在/e/class/functions.p…

这篇文章主要为大家分享下帝国cms相关链接无内容时调用当前栏目最热信息的方法,需要的朋友可以参考下

帝国cms相关链接,这里以帝国cms 7.0为例具体代码 在/e/class/functions.php

$keyboardtext='<?=GetKeyboard($ecms_gr[keyboard],$ecms_gr[keyid],$ecms_gr[classid],$ecms_gr[id],$class_r[$ecms_gr[classid]][link_num])?>';可以看到相关链接的信息是通过GetKeyboard得到,找到 GetKeyboard修改一下就可以了,也是在/e/class/functions.php

代码如下:

//取得相关链接

function GetKeyboard($keyboard,$keyid,$classid,$id,$link_num){
global $empire,$public_r,$class_r,$fun_r,$dbtbpre;

if($keyid&&$link_num)

{

$add="id in (".$keyid.")";

$tr=$empire->fetch1("select otherlinktemp,otherlinktempsub,otherlinktempdate from ".GetTemptb("enewspubtemp")." limit 1");//取得相关链接模板

$temp_r=explode("[!--empirenews.listtemp--]",$tr[otherlinktemp]);

$key_sql=$empire->query("select id,newstime,title,isurl,titleurl,classid,titlepic,lastvolume from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$add." order by newstime desc limit $link_num");

while($link_r=$empire->fetch($key_sql))

{

$text=RepOtherTemp($temp_r[1],$link_r,$tr);

$text=str_replace('[!--no--]',$i,$text);

$text=str_replace('[!--state--]',$link_r[state],$text);

$text=str_replace('[!--lastvolume--]',$link_r[lastvolume],$text);

$keyboardtext.=$text;

//$keyboardtext.=RepOtherTemp($temp_r[1],$link_r,$tr);

}

$keyboardtext=$temp_r[0].$keyboardtext.$temp_r[2];

}

else

{

$keyid=GetKeyid($keyboard,$classid,0,$link_num);
if($keyid)

{

$fsql=$empire->query("update {$dbtbpre}ecms_".$class_r[$classid][tbname]."_data_1 set keyid='$keyid' where id='$id'");

$add="id in (".$keyid.")";

$tr=$empire->fetch1("select otherlinktemp,otherlinktempsub,otherlinktempdate from ".GetTemptb("enewspubtemp")." limit 1");//取得相关链接模板

$temp_r=explode("[!--empirenews.listtemp--]",$tr[otherlinktemp]);

$key_sql=$empire->query("select id,newstime,title,isurl,titleurl,classid,titlepic,lastvolume from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$add." order by newstime desc limit $link_num");

while($link_r=$empire->fetch($key_sql))

{

$text=RepOtherTemp($temp_r[1],$link_r,$tr);

$text=str_replace('[!--no--]',$i,$text);

$text=str_replace('[!--state--]',$link_r[state],$text);

$text=str_replace('[!--lastvolume--]',$link_r[lastvolume],$text);

$keyboardtext.=$text;

//$keyboardtext.=RepOtherTemp($temp_r[1],$link_r,$tr);

}

$keyboardtext=$temp_r[0].$keyboardtext.$temp_r[2];

}

else

{

$add="";

$tr=$empire->fetch1("select otherlinktemp,otherlinktempsub,otherlinktempdate from ".GetTemptb("enewspubtemp")." limit 1");//取得相关链接模板

$temp_r=explode("[!--empirenews.listtemp--]",$tr[otherlinktemp]);

$key_sql=$empire->query("select id,newstime,title,isurl,titleurl,classid,titlepic,lastvolume from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where order by onclick desc limit $link_num");

while($link_r=$empire->fetch($key_sql))

{

$text=RepOtherTemp($temp_r[1],$link_r,$tr);

$text=str_replace('[!--no--]',$i,$text);

$text=str_replace('[!--state--]',$link_r[state],$text);

$text=str_replace('[!--lastvolume--]',$link_r[lastvolume],$text);

$keyboardtext.=$text;

//$keyboardtext.=RepOtherTemp($temp_r[1],$link_r,$tr);

}

$keyboardtext=$temp_r[0].$keyboardtext.$temp_r[2];

}

//----------------------------------------------------------------------------------------------

//$keyboardtext=$fun_r['NotLinkNews'];

}

return $keyboardtext;

}

原来的官方代码

在没有关键字的时候直接就给出

$keyboardtext=$fun_r['NotLinkNews'];

这显示无相关信息

我做了一个无keyid的时候再去获取一次keyid,

$keyid=GetKeyid($keyboard,$classid,0,$link_num);

确实没有关键字的时候读取人气最高的几条信息

$key_sql=$empire->query("select id,newstime,title,isurl,titleurl,classid,titlepic,lastvolume from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where order by onclick desc limit $link_num");

 

 

本文来自网络,不代表1号站长-站长学院|资讯交流平台立场。转载请注明出处: https://www.1cn.cc/jianzhan/diguo/17278.html
上一篇帝国cms 从6.6升级到7.0 Multiple primary key defined解决方法
下一篇 帝国CMS7.0后台关键字中文逗号和空格即时替换成英文逗号的方法
admin

作者: admin

这里可以再内容模板定义一些文字和说明,也可以调用对应作者的简介!或者做一些网站的描述之类的文字或者HTML!

为您推荐

评论列表()

    联系我们

    联系我们

    0898-88888888

    在线咨询: QQ交谈

    邮箱: email@wangzhan.com

    工作时间:周一至周五,9:00-17:30,节假日休息

    关注微信
    微信扫一扫关注我们

    微信扫一扫关注我们

    关注微博
    返回顶部