方法一:
活用zbp的模板语法就可以了,一般模板文件index.php下有这一段代码:
{foreach $articles as $article}
{if $article.IsTop}
{template:post-istop}
{else}
{template:post-multi}
{/if}
{/foreach}假设不显示分类ID为2的文章,改成这样:
{foreach $articles as $article}
{if $article.IsTop}
{template:post-istop}
{else}
{if $type=='index' && $page==1 && $article.Category.ID==2}
{else}
{template:post-multi}
{/if}
{/if}
{/foreach}方法二:挂接接口
打开主题目录下的include.php文件,挂载插件接口:
Add_Filter_Plugin('Filter_Plugin_ViewList_Core','主题ID_articles_xs');示例:
function ActivePlugin_主题ID(){
Add_Filter_Plugin('Filter_Plugin_ViewList_Core','主题ID_articles_xs');
}关于挂载接口的详细说明 实例演示如何为Z-BlogPHP添加自定义字段 ;
函数体:
function 主题ID_articles_xs(&$type,&$page,&$category,&$author,&$datetime,&$tag,&$w,&$pagebar){
if($type == 'index'){$w[]=array('<>','log_CateID',需要屏蔽的分类ID);}
}将这段代码添加到 include.php 文件中的 ?> 前边;
添加完成以上两段代码后,首页就不会在显示被屏蔽的分类的文章了。
function zbnew_category(&$type,&$page,&$category,&$author,&$datetime,&$tag,&$w,&$pagebar){
global $zbp;
if($type == 'index'){
$w[]=array('<>','log_CateID',5);
//重建分类
$pagebar = new Pagebar($zbp->option['ZC_INDEX_REGEX']);
$pagebar->PageCount = $zbp->displaycount;
$pagebar->PageNow = $page;
$pagebar->PageBarCount = $zbp->pagebarcount;
}
}这里我们可以在"include.php"主题文件中添加上面代码,记得上面的数字ID是我们需要不在首页显示的。
同时,我们需要创建"ActivePlugin_主题ID(){}"激活。
Add_Filter_Plugin('Filter_Plugin_ViewList_Core','zbnew_category');保存include.php文件 刷新主页试试,我们看看指定的5分类ID的分类是不是在首页有内容看到。
仔细查看include.php文件,找到当前主题的加载函数(function ActivePlugin_主题名)
在函数题中添加代码:
Add_Filter_Plugin('Filter_Plugin_ViewList_Core','zbnew_category');保存include.php文件 刷新主页试试
转载请说明出处
留余网 » zblog不显示指定分类方法大全,首页排除指定栏目内容
留余网 » zblog不显示指定分类方法大全,首页排除指定栏目内容