惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
SegmentFault 最新的问题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Attack and Defense Labs
Attack and Defense Labs
F
Full Disclosure
Vercel News
Vercel News
N
News | PayPal Newsroom
The GitHub Blog
The GitHub Blog
H
Hacker News: Front Page
H
Heimdal Security Blog
P
Privacy International News Feed
博客园 - 司徒正美
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cisco Blogs
L
Lohrmann on Cybersecurity
D
Docker
Recent Announcements
Recent Announcements
Security Archives - TechRepublic
Security Archives - TechRepublic
人人都是产品经理
人人都是产品经理
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Proofpoint News Feed
T
Tailwind CSS Blog
C
Check Point Blog
博客园 - 叶小钗
Google Online Security Blog
Google Online Security Blog
Martin Fowler
Martin Fowler
Stack Overflow Blog
Stack Overflow Blog
博客园 - 聂微东
S
Secure Thoughts
博客园 - Franky
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
P
Palo Alto Networks Blog
Latest news
Latest news
量子位
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog
Last Week in AI
Last Week in AI
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Cyberwarzone
Cyberwarzone
小众软件
小众软件
Cisco Talos Blog
Cisco Talos Blog
Hacker News: Ask HN
Hacker News: Ask HN
T
Threatpost
T
Tenable Blog
P
Privacy & Cybersecurity Law Blog
WordPress大学
WordPress大学

Typecho Official Site - 性能优化

评论验证码插件 - Typecho Official Site
如何使你的typecho更加精彩之一 - Typecho Official Site
作者:joyqi · 2009-07-13 · via Typecho Official Site - 性能优化

随着typecho用户越来越多,大家对个性化的需求也越来越强,其实typecho自身有很多自定义的功能,受于文档缺乏的限制一直不为大家发现,现在我在这里给大家略说一二

我在哪?

这是一个非常常用的功能,简单来说就是告诉模板现在是哪个页面,这样我们在模板里就可以用简单的判断语句来实现特殊效果。typecho已经内置了强大的is方法来供大家判断当前页面。

比如,我想在进入文章页面时,在右侧边栏中显示一段广告代码,我们就可以这么写

is('post')): ?> 我的广告来了

如果我想在某一则页面,比如说about页面显示时,让它显示一段广告代码,那么可以这么写

is('page', 'about')): ?> 我的广告来了

那么,有哪些页面是可以供判断的呢,答案是所有的页面,他们的参数如下

  1. index:第一个参数设为index,可以判断当前页是否为主页
  2. archive:第一个参数设为archive,可以判断当前页是否为文章归档页,比主页,分类文章页,标签文章页,日期归档文章页
  3. category:第一个参数设为category,可以判断当前页是否为分类文章页,第二个参数传入具体分类slug name,比如default等等,就可以判断具体是哪个分类
  4. tag:第一个参数设为tag,可以判断当前页是否为标签文章页,第二个参数传入具体标签slug name,比如typecho等等,就可以判断具体是哪个标签
  5. date:第一个参数设为date,可以判断当前页是否为日期归档文章页,第二个参数传入year,month或者day,就可以判断是否为按年,按月还是按日归档
  6. single:第一个参数设为single,可以判断当前页是否为内容页,比如文章页,独立页面,附件显示页
  7. post:第一个参数设为post,可以判断当前页是否为内容页,第二个参数传入文章id,就可以判断具体是哪篇文章
  8. page:第一个参数设为page,可以判断当前页是否为独立页面,第二个参数传入页面slug name比如about,就可以判断具体是哪则独立页面
  9. attachment:第一个参数设为attachment,可以判断当前页是否为附件,第二个参数传入附件id,就可以判断具体是哪个附件

细心的朋友可能已经看出,上面的判断有明显的层次之分,他们从上到下互相包含,这样做有什么作用呢,下一次继续与大家分享typecho强大的模板结构.

标签:typecho