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

荣誉就像河流:轻浮的和空虚的荣誉浮在河面上,沉重的和厚实的荣誉沉在河底里。雨会停,心会晴,没有什么会永远糟糕透顶。

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

打开织梦/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 rel="nofollow noopener noreferrer" 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 rel="nofollow noopener noreferrer" 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 rel="nofollow noopener noreferrer" 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 rel="nofollow noopener noreferrer" 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 rel="nofollow noopener noreferrer" href="'.$arcurl.'" title="'.$arr["shorttitle'].'">'.$arr['shorttitle'].'</a>';
	}
	return $li;
	}
	

织梦调用方法:

	
	{dede:field.id function=jjGetHotSearch(@me)/}
	

其他函数调用方法类似。

到此这篇关于DedeCMS列表页获取热搜排行榜文章的方法就介绍到这了。青春就像一颗梅花树,是那样的坚强,又是那样的脆弱,她在寒冬腊月奔放,又在阳春三月凋落,她是默默无闻,但是向往未来的,充满激情的!更多相关DedeCMS列表页获取热搜排行榜文章的方法内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!

标签: DedeCMS