首页 未命名内容详情

Zblog:如何在内容页调用本栏目最新和最热文章?

2026-01-10 3 897698882
Zblog:如何在内容页调用本栏目最新和最热文章?

站点名称:Zblog:如何在内容页调用本栏目最新和最热文章?

所属分类:未命名

官方网址:

SEO查询: 爱站网 站长工具

进入网站

站点介绍

步骤:

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}