花褪残红青杏小。燕子飞时,绿水人家绕。

ZBP首页及列表页分离以及首页不显示置顶的方法

ZBLOG教程 十五楼的鸟儿 21764浏览 0评论

文章部分内容取自官方wiki,只是很多人不看wiki...所以... 依然感谢月木。


首页和列表页分离的方法:

1、任意一个主题,把模板目录中的index.php复制出三份,分别命名为index.php,index_default.php,index_list.php。

2、将index.php内容清空,写入如下内容。

{if $type=='index'&&$page=='1'}
{template:index_default}
{else}
{template:index_list}
{/if}

3、进阶的,你可以把建立多个列表页,区分cate,tag,page,article等页面,设置有多个不同的模板。

{if $type=='index'&&$page=='1'}  /*判断首页*/
{template:index_default}
{elseif $type=='category'}  /*判断分类页*/
{template:index_cate}
{elseif $type=='article'}  /*判断日志页,不含独立页面*/
{template:index_artile}
{elseif $type=='page'}  /*判断独立页面*/
{template:index_page}
{elseif $type=='author'}  /*判断用户页*/
{template:index_author}
{elseif $type=='date'}  /*判断日期页*/
{template:index_date}
{elseif $type=='tag'}  /*判断标签页*/
{template:index_tag}
{/if}

首页不显示置顶文章,但是分类页保持显示的方法:

    1、此方法需要你先参照首页和列表页分离的方法,建立index.php, index_default.php和index_list.php。

    2、在index_default.php当中找到如下代码:

{foreach $articles as $article}

{if $article.IsTop}
{template:post-istop}
{else}
{template:post-multi}
{/if}

{/foreach}

修改为:

{foreach $articles as $article}

{if $article.IsTop}
{else}
{template:post-multi}
{/if}

{/foreach}

也就是检测到循环的时候遇到置顶文章,那么不再显示,此方法不同于css的display:none,不会在网页源代码中显示。

转载请注明:鸟儿博客 » ZBP首页及列表页分离以及首页不显示置顶的方法

与本文相关的文章

游客
发表我的评论 换个身份
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址