Zblog:如何在内容页调用本栏目最新和最热文章?
分类:zblog教程
36
步骤:
1.找到主题include.php文件;创建最新、最热方法,放置在include.php最下面;
San_Tiger_GetArticleCategorys_new
San_Tiger_GetArticleCategorys_hot
最新文章:
function San_Tiger_GetArticleCategorys_new($Rows,$CategoryID,$hassubcate){
global $zbp;
$ids = strpos($CategoryID,',') !== false ? explode(',',$CategoryID) : array($CategoryID);
$wherearray=array();
foreach ($ids as $cateid){
if (!$hassubcate) {
$wherearray[]=array('log_CateID',$cateid);
}else{
$wherearray[] = array('log_CateID', $cateid);
foreach ($zbp->categorys[$cateid]->SubCategorys as $subcate) {
$wherearray[] = array('log_CateID', $subcate->ID);
}
}
}
$where=array(
array('array',$wherearray),
array('=','log_Status','0'),
);
$order = array('log_PostTime'=>'DESC');
$articles= $zbp->GetArticleList(array('*'),$where,$order,array($Rows),'');
return $articles;
}最热文章:
function San_Tiger_GetArticleCategorys_hot($Rows,$CategoryID,$hassubcate){
global $zbp;
$ids = strpos($CategoryID,',') !== false ? explode(',',$CategoryID) : array($CategoryID);
$wherearray=array();
foreach ($ids as $cateid){
if (!$hassubcate) {
$wherearray[]=array('log_CateID',$cateid);
}else{
$wherearray[] = array('log_CateID', $cateid);
foreach ($zbp->categorys[$cateid]->SubCategorys as $subcate) {
$wherearray[] = array('log_CateID', $subcate->ID);
}
}
}
$where=array(
array('array',$wherearray),
array('=','log_Status','0'),
);
$order = array('log_ViewNums'=>'DESC');
$articles= $zbp->GetArticleList(array('*'),$where,$order,array($Rows),'');
return $articles;
}
2.在内容页模板 post-single.php文件中,调用循环:
{foreach $array=San_Tiger_GetArticleCategorys_hot(6,$article.Category.ID,true) as $related}
<li>
<a href="{$related.Url}" target="_blank">
<i>
{if $related->Metas->listimg}
{php}$listimg = $related->Metas->listimg;$src=FY_IMG::getPicUrlBy("$listimg",120,70,4);{/php}
<img src="{$src}" alt="{$related.Title}" />
{else}
{php}FY_IMG::getPics($related,210,142,4){/php}
{if $related->fy_img_count>0}
<img src="{$related.fy_img[0]}" alt="{$related.Title}" />
{else}
{php}$randimg=rand(1,5);{/php}
{php}$src=FY_IMG::getPicUrlBy("{$host}zb_users/theme/San_Tiger/style/img/{$randimg}.jpg",120,70,4){/php}
<img src="{$src}" alt="{$related.Title}" />
{/if}
{/if}
</i>
<h2>{$related.Title}</h2>
<span>{$related.Time('Y-m-d')}</span>
</a>
</li>
{/foreach} 最新发布
-
zblog响应式自媒体博客主题63号
2026-04-08 -
zblog响应式资讯门户主题62号
2026-04-05 -
zblog响应式文章自媒体资讯主题61号
2026-04-01 -
zblog响应式自媒体资讯主题60号
2026-03-30 -
zblog响应式门户文章资讯主题59号
2026-03-29
热门文章
-
ZBLOG精品手赚APP应用下载主题19号
1225 -
zblog响应式机器设备企业主题10号
1220 -
zblog响应式生活分类信息主题2号
937 -
zblog响应式机械企业外贸主题6号
320 -
简洁大气zblog响应式文章主题52号
306