single.php是Z-BlogPHP的内容页面模版,其大体的构造可以参考index.php,部分细节有区别。index.php的教程我写的比较简洁,这个我准备采用循规蹈矩的方法。
首先,我们看下single.php模版的基本组成部分:
Markup
{template:header}<body> …… <div> {if $article.Type==ZC_POST_TYPE_ARTICLE} {template:post-single} {else} {template:post-page} {/if} </div> <div> {template:sidebar} </div>{template:footer}
模版调用顶部页面header.php和底部页面footer.php。中间内容分了两部分:侧栏模版sidebar.php和一个 if
逻辑判断出来的模版。
它和index.php模版所不同之处是调用的内容不同,index.php是以列表为主的多个文章,而single.php是针对单个文章。至于post-single.php和post-page.php两者的不同,下一章节我们会继续详细讲解。
另外,用于文章列表的index.php模版只能通过分类管理来进行选择,而文章内容模版single.php可针对于每篇文章来选择。我们可以通过后来的“文章编辑”,在提交按钮下面找到需要使用的模版: