Typecho中常用的调用函数

2017年8月20日23:29:48 发表评论 479 views
爱搜券优惠券网

下面是相关的函数

1、站点名称


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">options</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">title</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token delimiter">?&gt;</span></span>

2、站点网址


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">options</span> <span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">siteUrl</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

3、完整路径标题如分享几个Typecho中常用的调用函数


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">archiveTitle</span><span class="token punctuation">(</span><span class="token string">' &amp;raquo; '</span><span class="token punctuation">,</span> <span class="token markup">&lt; span class="string"&gt;</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">' | '</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span> <span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">options</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">title</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

4、站点说明


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">options</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">description</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token delimiter">?&gt;</span></span>

5、模板文件夹地址


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">options</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">themeUrl</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

6、导入模板文件夹内的php文件


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token markup">&lt; /span&gt;</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">need</span><span class="token punctuation">(</span><span class="token string">'.php'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

7、文章或者页面的作者


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">author</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

8、作者头像


1
<span class="token markup">&lt; ?php $this-&gt;</span>author<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">gravatar</span><span class="token punctuation">(</span><span class="token string">'40'</span><span class="token punctuation">)</span> <span class="token delimiter">?&gt;</span>

此处输出的完整的img标签,40是头像的宽和高。

9、该文作者全部文章列表链接


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">author</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">permalink</span> <span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

10、该文作者个人主页链接


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">author</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">url</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

11 、该文作者的邮箱地址


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">author</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">mail</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

12、上一篇与下一篇调用代码


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">thePrev</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span> <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">theNext</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

13、判断是否为首页,输出相关内容


1
2
3
4
5
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">is</span><span class="token punctuation">(</span><span class="token string">'index'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span>
<span class="token comment" spellcheck="true">//首页输出内容</span>
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">else</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span>
<span class="token comment" spellcheck="true">//不是首页输出内容</span>
<span class="token markup">&lt; span&gt;</span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">endif</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

14、文章或页面,评论数目


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">commentsNum</span><span class="token punctuation">(</span><span class="token string">'No Comments'</span><span class="token punctuation">,</span> <span class="token string">'1 Comment'</span> <span class="token punctuation">,</span> <span class="token string">'%d Comments'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

14、文章或页面,评论数目


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">commentsNum</span><span class="token punctuation">(</span><span class="token string">'No Comments'</span><span class="token punctuation">,</span> <span class="token string">'1 Comment'</span> <span class="token punctuation">,</span> <span class="token string">'%d Comments'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

15、截取部份文章(首页每篇文章显示摘要),350是字数


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">excerpt</span><span class="token punctuation">(</span><span class="token number">350</span><span class="token punctuation">,</span> <span class="token string">'.. .'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

16、调用自定义字段(官方文档坑爹,竟然没有,博主自己摸索出来的)


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">fields</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">fieldName</span> <span class="token delimiter">?&gt;</span></span>

17、RSS地址


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">options</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">feedUrl</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

18、获取最新post


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">widget</span><span class="token punctuation">(</span><span class="token string">'Widget_Contents_Post_Recent'</span><span class="token punctuation">,</span> <span class="token string">'pageSize=8&amp;type=category'</span><span class="token punctuation">)</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">parse</span><span class="token punctuation">(</span>'<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>li<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>a <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>{permalink}<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span><span class="token punctuation">{</span>title<span class="token punctuation">}</span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>a<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>li<span class="token punctuation">&gt;</span></span></span>'<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

19、纯文字分类名称,不带链接


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">category</span><span class="token punctuation">(</span><span class="token string">','</span><span class="token punctuation">,</span> <span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

20、获取文章分类列表


1
2
3
4
<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>ul<span class="token punctuation">&gt;</span></span></span>
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">widget</span><span class="token punctuation">(</span><span class="token string">'Widget_Metas_Category_List'</span><span class="token punctuation">)</span>
                <span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">parse</span><span class="token punctuation">(</span>'<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>li<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>a <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>{permalink}<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span><span class="token punctuation">{</span>name<span class="token punctuation">}</span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>a<span class="token punctuation">&gt;</span></span></span> <span class="token punctuation">(</span><span class="token punctuation">{</span>count<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>li<span class="token punctuation">&gt;</span></span></span>'<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>
<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>ul<span class="token punctuation">&gt;</span></span></span>

21、获取某分类post


1
2
3
4
5
<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>ul<span class="token punctuation">&gt;</span></span></span>
<span class="token php"><span class="token delimiter">&lt;?php</span>
<span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">widget</span><span class="token punctuation">(</span><span class="token string">'Widget_Archive@indexyc'</span><span class="token punctuation">,</span> <span class="token string">'pageSize=8&amp;type=category'</span><span class="token punctuation">,</span> <span class="token string">'mid=1'</span><span class="token punctuation">)</span>
<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">parse</span><span class="token punctuation">(</span>'<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>li<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>a <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>{permalink}<span class="token punctuation">"</span></span> <span class="token attr-name">title</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>{title}<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span><span class="token punctuation">{</span>title<span class="token punctuation">}</span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>a<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>li<span class="token punctuation">&gt;</span></span></span>'<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>
<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>ul<span class="token punctuation">&gt;</span></span></span>

22、获取最新评论列表


1
2
3
4
5
6
<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>ul<span class="token punctuation">&gt;</span></span></span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">widget</span><span class="token punctuation">(</span><span class="token string">'Widget_Comments_Recent'</span><span class="token punctuation">)</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">to</span><span class="token punctuation">(</span><span class="token variable">$comments</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">while</span><span class="token punctuation">(</span><span class="token variable">$comments</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span>
        <span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>li<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>a <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$comments</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">permalink</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$comments</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">author</span><span class="token punctuation">(</span><span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>a<span class="token punctuation">&gt;</span></span></span><span class="token punctuation">:</span> <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$comments</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">excerpt</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">,</span> <span class="token string">'...'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>li<span class="token punctuation">&gt;</span></span></span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">endwhile</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>
<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>ul<span class="token punctuation">&gt;</span></span></span>

23、首页获取 最新文章 代码限制条数


1
2
3
4
5
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span>
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">sequence</span> <span class="token markup">&lt;= 3): ?&gt;</span></span>
html
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">endif</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">endwhile</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

24、获取最新评论列表第二个版本,只显示访客评论不显示博主也就是作者或者说自己发的评论


1
2
3
4
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">widget</span><span class="token punctuation">(</span><span class="token string">'Widget_Comments_Recent'</span><span class="token punctuation">,</span><span class="token string">'ignoreAuthor=true'</span><span class="token punctuation">)</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">to</span><span class="token punctuation">(</span><span class="token variable">$comments</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">while</span><span class="token punctuation">(</span><span class="token variable">$comments</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span>
    <span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>li<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>a <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$comments</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">permalink</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$comments</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">author</span><span class="token punctuation">(</span><span class="token boolean">false</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>a<span class="token punctuation">&gt;</span></span></span><span class="token punctuation">:</span> <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$comments</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">excerpt</span><span class="token punctuation">(</span><span class="token number">50</span><span class="token punctuation">,</span> <span class="token string">'...'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>li<span class="token punctuation">&gt;</span></span></span>
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">endwhile</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

25、获取文章时间归档


1
2
3
4
<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>ul<span class="token punctuation">&gt;</span></span></span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">widget</span><span class="token punctuation">(</span><span class="token string">'Widget_Contents_Post_Date'</span><span class="token punctuation">,</span> <span class="token string">'type=month&amp;format=F Y'</span><span class="token punctuation">)</span>
                <span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">parse</span><span class="token punctuation">(</span>'<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>li<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>a <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>{permalink}<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span><span class="token punctuation">{</span>date<span class="token punctuation">}</span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>a<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>li<span class="token punctuation">&gt;</span></span></span>'<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>
<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>ul<span class="token punctuation">&gt;</span></span></span>

26、获取标签集合,也就是标签云


1
2
3
4
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">widget</span><span class="token punctuation">(</span><span class="token string">'Widget_Metas_Tag_Cloud'</span><span class="token punctuation">,</span> <span class="token string">'ignoreZeroCount=1&amp;limit=28'</span><span class="token punctuation">)</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">to</span><span class="token punctuation">(</span><span class="token variable">$tags</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">while</span><span class="token punctuation">(</span><span class="token variable">$tags</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span>
<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>a <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$tags</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">permalink</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token punctuation">"</span></span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>size-<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$tags</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">,</span> <span class="token number">30</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$tags</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>a<span class="token punctuation">&gt;</span></span></span>
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">endwhile</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

27、调用该文相关文章列表


1
2
3
4
5
6
7
8
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">related</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">to</span><span class="token punctuation">(</span><span class="token variable">$relatedPosts</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$relatedPosts</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">have</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span>    <span class="token comment" spellcheck="true">//这句也可以写成 if (count($relatedPosts-&gt;stack))</span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">while</span> <span class="token punctuation">(</span><span class="token variable">$relatedPosts</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span>
        <span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>li<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>a <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$relatedPosts</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">permalink</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token punctuation">"</span></span> <span class="token attr-name">title</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$relatedPosts</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">title</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$relatedPosts</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">title</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>a<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>li<span class="token punctuation">&gt;</span></span></span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">endwhile</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">else</span> <span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span>
        <span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>li<span class="token punctuation">&gt;</span></span></span>无相关文章<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>li<span class="token punctuation">&gt;</span></span></span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">endif</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

28、隐藏head区域的程序版本和模版名称


1
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">header</span><span class="token punctuation">(</span><span class="token string">"generator=&amp;template="</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

29、获取读者墙


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<span class="token php"><span class="token delimiter">&lt;?php</span>
<span class="token variable">$period</span> <span class="token operator">=</span> <span class="token function">time</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">-</span> <span class="token number">999592000</span><span class="token punctuation">;</span> <span class="token comment" spellcheck="true">// 時段: 30 天, 單位: 秒</span>
<span class="token variable">$counts</span> <span class="token operator">=</span> <span class="token scope">Typecho_Db<span class="token punctuation">::</span></span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">fetchAll</span><span class="token punctuation">(</span><span class="token scope">Typecho_Db<span class="token punctuation">::</span></span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">select</span><span class="token punctuation">(</span><span class="token string">'COUNT(author) AS cnt'</span><span class="token punctuation">,</span><span class="token string">'author'</span><span class="token punctuation">,</span> <span class="token string">'url'</span><span class="token punctuation">,</span> <span class="token string">'mail'</span><span class="token punctuation">)</span>
<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">from</span><span class="token punctuation">(</span><span class="token string">'table.comments'</span><span class="token punctuation">)</span>
<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">where</span><span class="token punctuation">(</span><span class="token string">'created &gt; ?'</span><span class="token punctuation">,</span> <span class="token variable">$period</span> <span class="token punctuation">)</span>
<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">where</span><span class="token punctuation">(</span><span class="token string">'status = ?'</span><span class="token punctuation">,</span> <span class="token string">'approved'</span><span class="token punctuation">)</span>
<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">where</span><span class="token punctuation">(</span><span class="token string">'type = ?'</span><span class="token punctuation">,</span> <span class="token string">'comment'</span><span class="token punctuation">)</span>
<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">where</span><span class="token punctuation">(</span><span class="token string">'authorId = ?'</span><span class="token punctuation">,</span> <span class="token string">'0'</span><span class="token punctuation">)</span>
<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">group</span><span class="token punctuation">(</span><span class="token string">'author'</span><span class="token punctuation">)</span>
<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">order</span><span class="token punctuation">(</span><span class="token string">'cnt'</span><span class="token punctuation">,</span> <span class="token scope">Typecho_Db<span class="token punctuation">::</span></span><span class="token constant">SORT_DESC</span><span class="token punctuation">)</span>
<span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">limit</span><span class="token punctuation">(</span><span class="token number">25</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token variable">$mostactive</span> <span class="token operator">=</span> <span class="token string">''</span><span class="token punctuation">;</span>
<span class="token variable">$avatar_path</span> <span class="token operator">=</span> 'http<span class="token punctuation">:</span><span class="token comment" spellcheck="true">//www.gravatar.com/avatar/';</span>
<span class="token keyword">foreach</span> <span class="token punctuation">(</span><span class="token variable">$counts</span> <span class="token keyword">as</span> <span class="token variable">$count</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token variable">$avatar</span> <span class="token operator">=</span> <span class="token variable">$avatar_path</span> <span class="token punctuation">.</span> <span class="token function">md5</span><span class="token punctuation">(</span><span class="token function">strtolower</span><span class="token punctuation">(</span><span class="token variable">$count</span><span class="token punctuation">[</span><span class="token string">'mail'</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">.</span> <span class="token string">'.jpg'</span><span class="token punctuation">;</span>
  <span class="token variable">$c_url</span> <span class="token operator">=</span> <span class="token variable">$count</span><span class="token punctuation">[</span><span class="token string">'url'</span><span class="token punctuation">]</span><span class="token punctuation">;</span> <span class="token keyword">if</span> <span class="token punctuation">(</span> <span class="token operator">!</span><span class="token variable">$c_url</span> <span class="token punctuation">)</span> <span class="token variable">$c_url</span> <span class="token operator">=</span> <span class="token scope">Helper<span class="token punctuation">::</span></span><span class="token function">options</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">siteUrl</span><span class="token punctuation">;</span>
  <span class="token variable">$mostactive</span> <span class="token punctuation">.</span><span class="token operator">=</span> "<span class="token markup">&lt;a href='" . $c_url . "' title='" . $count['author'] . " (参与" . $count['cnt'] . "次互动)' target='_blank'&gt;</span><span class="token markup">&lt;img src='" . $avatar . "' alt='" . $count['author'] . "的头像' class='avatar' width='32' height='32' /&gt;</span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>a<span class="token punctuation">&gt;</span></span></span>\<span class="token package">n</span>"<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">echo</span> <span class="token variable">$mostactive</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

30、登陆与未登录用户展示不同内容


1
2
3
4
5
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">user</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">hasLogin</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span>
登陆可见
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">else</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span>
未登录和登陆均可见
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">endif</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>

27、导航页面列表调用隐藏特定的页面 这个演示隐藏了album和search两个页面


1
2
3
4
5
6
7
8
9
<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>ul<span class="token punctuation">&gt;</span></span></span>
<span class="token markup">&lt;li<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">is</span><span class="token punctuation">(</span><span class="token string">'index'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span> class="current"<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">endif</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>&gt;</span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>a <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">options</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">siteUrl</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span>主页<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>a<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>li<span class="token punctuation">&gt;</span></span></span>
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">widget</span><span class="token punctuation">(</span><span class="token string">'Widget_Contents_Page_List'</span><span class="token punctuation">)</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">to</span><span class="token punctuation">(</span><span class="token variable">$pages</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">while</span><span class="token punctuation">(</span><span class="token variable">$pages</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">$pages</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">slug</span> <span class="token operator">!=</span> <span class="token string">'album'</span><span class="token punctuation">)</span> <span class="token operator">&amp;&amp;</span> <span class="token punctuation">(</span><span class="token variable">$pages</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">slug</span> <span class="token operator">!=</span> <span class="token string">'search'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span>
    <span class="token markup">&lt;li<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">is</span><span class="token punctuation">(</span><span class="token string">'page'</span><span class="token punctuation">,</span> <span class="token variable">$pages</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">slug</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token delimiter">?&gt;</span></span> class="current"<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">endif</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>&gt;</span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>a <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$pages</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">permalink</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token punctuation">"</span></span> <span class="token attr-name">title</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$pages</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">title</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span><span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token variable">$pages</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">title</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>a<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>li<span class="token punctuation">&gt;</span></span></span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">endif</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>
    <span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token keyword">endwhile</span><span class="token punctuation">;</span> <span class="token delimiter">?&gt;</span></span>
<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>ul<span class="token punctuation">&gt;</span></span></span>

参数说明
9.0版typecho支出在后台管理页面编辑时选择隐藏页面
27、Typecho归档页面(牧风提供)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<span class="token php"><span class="token delimiter">&lt;?php</span> <span class="token this">$this</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">widget</span><span class="token punctuation">(</span><span class="token string">'Widget_Contents_Post_Recent'</span><span class="token punctuation">,</span> <span class="token string">'pageSize=10000'</span><span class="token punctuation">)</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">to</span><span class="token punctuation">(</span><span class="token variable">$archives</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token variable">$year</span><span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span> <span class="token variable">$mon</span><span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span> <span class="token variable">$i</span><span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span> <span class="token variable">$j</span><span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>
    <span class="token variable">$output</span> <span class="token operator">=</span> '<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>div <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>archives<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span>'<span class="token punctuation">;</span>
    <span class="token keyword">while</span><span class="token punctuation">(</span><span class="token variable">$archives</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token function">next</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">:</span>
        <span class="token variable">$year_tmp</span> <span class="token operator">=</span> <span class="token function">date</span><span class="token punctuation">(</span><span class="token string">'Y'</span><span class="token punctuation">,</span><span class="token variable">$archives</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">created</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token variable">$mon_tmp</span> <span class="token operator">=</span> <span class="token function">date</span><span class="token punctuation">(</span><span class="token string">'m'</span><span class="token punctuation">,</span><span class="token variable">$archives</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">created</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token variable">$y</span><span class="token operator">=</span><span class="token variable">$year</span><span class="token punctuation">;</span> <span class="token variable">$m</span><span class="token operator">=</span><span class="token variable">$mon</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$mon</span> <span class="token operator">!=</span> <span class="token variable">$mon_tmp</span> <span class="token operator">&amp;&amp;</span> <span class="token variable">$mon</span> <span class="token operator">&gt;</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token variable">$output</span> <span class="token punctuation">.</span><span class="token operator">=</span> '<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>ul<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>li<span class="token punctuation">&gt;</span></span></span>'<span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$year</span> <span class="token operator">!=</span> <span class="token variable">$year_tmp</span> <span class="token operator">&amp;&amp;</span> <span class="token variable">$year</span> <span class="token operator">&gt;</span> <span class="token number">0</span><span class="token punctuation">)</span> <span class="token variable">$output</span> <span class="token punctuation">.</span><span class="token operator">=</span> '<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>ul<span class="token punctuation">&gt;</span></span></span>'<span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$year</span> <span class="token operator">!=</span> <span class="token variable">$year_tmp</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token variable">$year</span> <span class="token operator">=</span> <span class="token variable">$year_tmp</span><span class="token punctuation">;</span>
            <span class="token variable">$output</span> <span class="token punctuation">.</span><span class="token operator">=</span> '<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>h3 <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>al_year<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span><span class="token string">'. $year .'</span> 年<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>h3<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>ul <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>al_mon_list<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span>'<span class="token punctuation">;</span> <span class="token comment" spellcheck="true">//输出年份</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$mon</span> <span class="token operator">!=</span> <span class="token variable">$mon_tmp</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token variable">$mon</span> <span class="token operator">=</span> <span class="token variable">$mon_tmp</span><span class="token punctuation">;</span>
            <span class="token variable">$output</span> <span class="token punctuation">.</span><span class="token operator">=</span> '<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>li<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>span <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>al_mon<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span><span class="token string">'. $mon .'</span> 月<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>span<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>ul <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>al_post_list<span class="token punctuation">"</span></span><span class="token punctuation">&gt;</span></span></span>'<span class="token punctuation">;</span> <span class="token comment" spellcheck="true">//输出月份</span>
        <span class="token punctuation">}</span>
        <span class="token variable">$output</span> <span class="token punctuation">.</span><span class="token operator">=</span> '<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>li<span class="token punctuation">&gt;</span></span></span><span class="token string">'.date('</span>d日<span class="token punctuation">:</span> <span class="token string">',$archives-&gt;created).'</span><span class="token markup">&lt;a href="'.$archives-&gt;</span>permalink <span class="token punctuation">.</span><span class="token string">'"&gt;'</span><span class="token punctuation">.</span> <span class="token variable">$archives</span><span class="token operator">-</span><span class="token operator">&gt;</span><span class="token property">title</span> <span class="token punctuation">.</span>'<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>a<span class="token punctuation">&gt;</span></span></span> <span class="token markup"><span class="token tag"><span class="token punctuation">&lt;</span>em<span class="token punctuation">&gt;</span></span></span><span class="token punctuation">(</span><span class="token string">'. $archives-&gt;commentsNum.'</span><span class="token punctuation">)</span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>em<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>li<span class="token punctuation">&gt;</span></span></span>'<span class="token punctuation">;</span> <span class="token comment" spellcheck="true">//输出文章日期和标题</span>
    <span class="token keyword">endwhile</span><span class="token punctuation">;</span>
    <span class="token variable">$output</span> <span class="token punctuation">.</span><span class="token operator">=</span> '<span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>ul<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>li<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>ul<span class="token punctuation">&gt;</span></span></span><span class="token markup"><span class="token tag"><span class="token punctuation">&lt;/</span>div<span class="token punctuation">&gt;</span></span></span>'<span class="token punctuation">;</span>
    <span class="token keyword">echo</span> <span class="token variable">$output</span><span class="token punctuation">;</span>
<span class="token delimiter">?&gt;</span></span>
  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin
admin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: