详情页

zblog添加列表页面tags

时间:2023年09月19日

编辑:佚名

 zblog前台页面本身是没有显示全部标签页面的,也没有显示全部分类页面和显示全部用户页面这类的,我们已经tags列表为例,讲下逻辑。步骤如下:
1、添加接口,用于添加设置tags列表的专用url地址并执行显示。
点击复制代码 PHP
Add_Filter_Plugin('Filter_Plugin_Index_Begin', 'tc_tags_Index_Begin');
2、设置url地址,伪静态情况下通过访问“域名/zhuanti”访问。
点击复制代码 PHP
function tc_tags_Index_Begin()
{
    global $zbp;
    if ($zbp->option['ZC_STATIC_MODE'] == 'REWRITE') {
        $zhuanti='zhuanti';
        if (stripos($zbp->currenturl, $zhuanti) === 1) {
            tc_tags_index();
            die();
        }
    }
}
3、设置tags列表页面的函数代码
点击复制代码 PHP
function tc_tags_index()
{
    global $zbp;
    $p = new Pagebar('{%host%}zhuanti/{%page%}', false);
    $b = explode('/', $zbp->currenturl);
    if(empty($b[2])){
        $page=1;
    }else{
        $page=(int)$b[2];
    }
    $p->PageCount = $zbp->option['ZC_DISPLAY_COUNT'];
    $p->PageNow=$page;
    $p->PageBarCount=$zbp->pagebarcount;
    $l = array(($p->PageNow - 1) * $p->PageCount, $p->PageCount);
    $op = array('pagebar' => $p);
    $w = array();
    $array = $zbp->GetTagList(null, $w, array('tag_ID' => 'DESC'), $l, $op);
    $article = new Post;
    $article->Title = 'tags列表';
    $article->Template = 'tc_list';
    $zbp->template->SetTags('articles', $array);
    $zbp->template->SetTags('title',$article->Title);
    $zbp->template->SetTags('article',$article);
    $zbp->template->SetTemplate($article->Template);
    $zbp->template->SetTags('page',$page);
    $zbp->template->SetTags('pagebar', $p);
    $zbp->template->Display();
    die();
}
Template是模板文件名。
4、编写前台界面
点击复制代码 PHP
{foreach $articles as $item}
{$item.Url}-{$item.Name}
{/foreach}
{template:pagebar}
5、完结。
相关文章
猜你需要