zblog php代码实现相关文章功能的方法
时间:2019-11-14
本文章向大家介绍zblog php代码实现相关文章功能的方法,主要包括zblog php代码实现相关文章功能的方法使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
我们在做zblog网站的时候,需要在文章页底部加上相关文章的功能,这无论是对搜索引擎还是用户体念都是非常有必要的。
下面来介绍一下实现功能的代码:
第一种可以使用官方推荐代码:
PHP
{$aid=$article.ID}{$tagid=$article.Tags}{$cid=$article.Category.ID}{php}
$str = '';
$tagrd=array_rand($tagid);
if( sizeof($tagid)>0 && ($tagid[$tagrd]->Count)>1){
$tagi='%{'.$tagrd.'}%';
$where = array(array('=','log_Status','0'),array('like','log_Tag',$tagi),array('<>','log_ID',$aid));
}else{
$where = array(array('=','log_Status','0'),array('=','log_CateID',$cid),array('<>','log_ID',$aid));
}
$array = $zbp->GetArticleList(array('*'),$where,array('rand()'=>' '),array(6),'');
foreach ($array as $related) {
if(($related->ID)!=$aid){
$str .= "<li><span class=\"time\">{$related->Time('m-d')}</span><span class=\"title\"><i class=\"icon-doc-text\"></i><a href=\"{$related->Url}\" title=\"{$related->Title}\">{$related->Title}</a></span><small class=\"pcomm\"><i class=\"icon-comment-1\"></i> <a href=\"{$related->Url}#comments\" rel=\"nofollow\" title=\"《{$related->Title}》上的评论\">{$related->CommNums}