阿里云服务器

我们在做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神马MIP搜索提交工具使用教程
  • zblog php判断用户登入和用户级别显示不同内容的方法
  • zblog调用自定义字段的方法
  • zblog php代码实现相关文章功能的方法
  • zblog php分类文章获取排序支持多个分类
  • zblog php通过代码实现首页调用缩略图的方法
  • zblog asp和php版忘记密码重置的方法
  • zblog文章图片自适应的设置方法
  • zblog火车头采集发布教程和模块
  • zblog数据库怎么转换到emlog