zblog首页和列表页分离 首页列表文章不显示置顶的方法
分类:zblog教程
30
我们在做zblog主题的时候,需要在分类列表中显示置顶文章,而在首页不显示。
所以需要先把首页和列表页分离开来,index.php复制出三份,分别命名为index.php,default.php,list.php等等
index.php插入下面代码:
{if $type=='index'&&$page=='1'} /*判断首页*/
{template:default}
{elseif $type=='category'} /*判断分类页*/
{template:list}
{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}具体文件名称自己定义就可以了。
我们在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}这样置顶文章就不会显示在首页了,并不影响列表页置顶文章的显示。
上一篇:zblog教程
最新发布
-
zblog响应式自媒体博客主题63号
2026-04-08 -
zblog响应式资讯门户主题62号
2026-04-05 -
zblog响应式文章自媒体资讯主题61号
2026-04-01 -
zblog响应式自媒体资讯主题60号
2026-03-30 -
zblog响应式门户文章资讯主题59号
2026-03-29
热门文章
-
ZBLOG精品手赚APP应用下载主题19号
1225 -
zblog响应式机器设备企业主题10号
1220 -
zblog响应式生活分类信息主题2号
939 -
zblog响应式机械企业外贸主题6号
320 -
简洁大气zblog响应式文章主题52号
306