Zblog如何在内容页调用本栏目最新和最热文章?
时间:2023年05月24日
/来源:网络
/编辑:佚名
步骤:
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}
复制代码
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}
复制代码
新闻资讯 更多
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 9帝国cms后台登录出现”您还未登录”怎么解决?
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法