在zblog首页调用不同栏目的列表数据

因为有些主题的原因,一些新加栏目不能按照需求,在首页调出部分列表数据。我们可以这样做:

1.找到该主题的include.php文件,在该文件最后添加代码如下:

注意:

San_Tiger_GetArticleCategorys函数名中,需要将 San_Tiger换成网站所正在用的主题名

function San_Tiger_GetArticleCategorys($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;
}

 在zblog首页调用不同栏目的列表数据

2.在后台主题编辑器,(如果没有安装主题编辑器,可以在服务器端找到该主题的index.php文件),修改template/index.php文件;

注意:使用foreach循环语句,包含San_Tiger_GetArticleCategorys(数据条数,'栏目id1,栏目id2,栏目id3',true)进行引用。栏目id可以单个可以多个。

 在zblog首页调用不同栏目的列表数据

 3.效果如图:

 在zblog首页调用不同栏目的列表数据

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容