php专区

 首页 > php专区 > PHP应用 > CMS建站 > 帝国cms相关链接无内容时调用当前栏目最热信息

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

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

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

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

$keyboardtext='';可以看到相关链接的信息是通过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))
{
//=========================================================2012-12-25 4usky.com
$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 zhuxianfei.com 2013/5/17 星期五
$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))
{
//=========================================================2012-12-25 4usky.com
$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 //没有关键字的时候读取人气最高的几条信息 2013/5/17 星期五 zhuxianfei.com
{
$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))
{
//=========================================================2012-12-25 4usky.com
$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");

分享到:
帝国cms选取两个表的集合实现按某字段排...
本文为大家介绍下帝国cms选取两个表的集合按某字段排序的具体实现,感兴趣的朋友不要错过 复制代码代码如下: 热门作品 [e:loop={'select title,titleurl,onclick,titlepic from `[!db.pre!]ecms_test` Union All select title,titleurl,onclick,titlepic from `[!db.pre!]ecms_gamepic` order by onclick ...
帝国CMS7.0使用常见问题小结_帝国cms_CMS...
这篇文章主要介绍下帝国CMS7.0的一些常见问题,需要的朋友可以参考下  一、7.0版本的数据库配置文件是哪个文件? 7.0版本数据库配置文件:/e/config/config.php6.6及以下版本数据库配置文件:/e/class/config.php   二、忘记后台登陆认证码怎么办?查看 /e/config/config.php 文件里的“$ecms_config['es...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……