织梦DedeCMS列表页获取热搜文章排行榜的方法

作者 : 官方 本文共2985个字,预计阅读时间需要8分钟 发布时间: 2020-07-30 共75人阅读

织梦网站有的时候需要在列表页调用搜索最多的文章列表,做一个展示,此时需要做下二次开发。

打开织梦/include/extend.func.php最后加上以下代码:

//列表页获取网友热搜 24小时
function jjGetHotSearch($tid){
global $dsql;
$time = time() – 86400;
$sql = “select * from dede_archives where typeid = ‘$tid’ and shorttitle <> ” group by shorttitle order by pubdate desc limit 10″;
$dsql->Execute(‘me’,$sql);
$li = ;
while($arr = $dsql->GetArray(‘me’))
{
if($arr[‘pubdate’] >$time ){
$class = ‘new’;
}else{
$class = ;
}
$barr = GetOneArchive($arr[‘id’]);
$arcurl = $barr[‘arcurl’];
$li .= ‘<li><span class=”right”><time class=”‘.$class.‘”>’.date(‘Y-m-d’,$arr[‘pubdate’]).‘</time></span><a href=”‘.$arcurl.‘” title=”‘.$arr[‘shorttitle’].‘”>’.$arr[‘shorttitle’].‘</a></li>’;
}
return $li;
}
//排行榜获取网友热搜 3天
function hot_3_GetHotSearch($tid){
global $dsql;
$time = time() – 86400;
$sql = “select * from dede_archives where pubdate > UNIX_TIMESTAMP( CURDATE( ) – INTERVAL 3 day) and typeid = ‘$tid’ and shorttitle <> ” group by shorttitle order by click desc limit 10″;
$dsql->Execute(‘me’,$sql);
$li = ;
while($arr = $dsql->GetArray(‘me’))
{
if($arr[‘pubdate’] >$time ){
$class = ‘new’;
}else{
$class = ;
}
$barr = GetOneArchive($arr[‘id’]);
$arcurl = $barr[‘arcurl’];
$li .= ‘<li><span class=”right”><time class=”‘.$class.‘”>’.date(‘Y-m-d’,$arr[‘pubdate’]).‘</time></span><a href=”‘.$arcurl.‘” title=”‘.$arr[‘shorttitle’].‘”>’.$arr[‘shorttitle’].‘</a></li>’;
}
return $li;
}
//排行榜获取网友热搜 7天
function hot_7_GetHotSearch($tid){
global $dsql;
$time = time() – 86400;
$sql = “select * from dede_archives where pubdate > UNIX_TIMESTAMP( CURDATE( ) – INTERVAL 7 day) and typeid = ‘$tid’ and shorttitle <> ” group by shorttitle order by click desc limit 10″;
$dsql->Execute(‘me’,$sql);
$li = ;
while($arr = $dsql->GetArray(‘me’))
{
if($arr[‘pubdate’] >$time ){
$class = ‘new’;
}else{
$class = ;
}
$barr = GetOneArchive($arr[‘id’]);
$arcurl = $barr[‘arcurl’];
$li .= ‘<li><span class=”right”><time class=”‘.$class.‘”>’.date(‘Y-m-d’,$arr[‘pubdate’]).‘</time></span><a href=”‘.$arcurl.‘” title=”‘.$arr[‘shorttitle’].‘”>’.$arr[‘shorttitle’].‘</a></li>’;
}
return $li;
}
//排行榜获取网友热搜 30天
function hot_30_GetHotSearch($tid){
global $dsql;
$time = time() – 86400;
$sql = “select * from dede_archives where pubdate > UNIX_TIMESTAMP( CURDATE( ) – INTERVAL 30 day) and typeid = ‘$tid’ and shorttitle <> ” group by shorttitle order by click desc limit 10″;
$dsql->Execute(‘me’,$sql);
$li = ;
while($arr = $dsql->GetArray(‘me’))
{
if($arr[‘pubdate’] >$time ){
$class = ‘new’;
}else{
$class = ;
}
$barr = GetOneArchive($arr[‘id’]);
$arcurl = $barr[‘arcurl’];
$li .= ‘<li><span class=”right”><time class=”‘.$class.‘”>’.date(‘Y-m-d’,$arr[‘pubdate’]).‘</time></span><a href=”‘.$arcurl.‘” title=”‘.$arr[‘shorttitle’].‘”>’.$arr[‘shorttitle’].‘</a></li>’;
}
return $li;
}
//列表页获取栏目关注 30天 14条
function hotword_30_GetHotSearch($tid){
global $dsql;
$time = time() – 86400;
$sql = “select * from dede_archives where pubdate > UNIX_TIMESTAMP( CURDATE( ) – INTERVAL 90 day) and typeid = ‘$tid’ and shorttitle <> ” group by shorttitle order by click desc limit 14″;
$dsql->Execute(‘me’,$sql);
$li = ;
while($arr = $dsql->GetArray(‘me’))
{
if($arr[‘pubdate’] >$time ){
$class = ‘new’;
}else{
$class = ;
}
$barr = GetOneArchive($arr[‘id’]);
$arcurl = $barr[‘arcurl’];
$li .= ‘<a href=”‘.$arcurl.‘” title=”‘.$arr[‘shorttitle’].‘”>’.$arr[‘shorttitle’].‘</a>’;
}
return $li;
}

IT速极网-【教程资源】 » 织梦DedeCMS列表页获取热搜文章排行榜的方法

常见问题FAQ

RD.IT速极网可以技术支持吗?
需要技术技术资源联系客服即可!

发表评论