这些都是Typecho常用的标签函数,整理在此处主要是方便首次修改Typecho代码或者不想去Typecho文档站点 - Typecho Docs查看官方文档。当然,如果要设计主题模板,或者开发插件等,还是的查官方文档。

一、站点相关

1. 站点名称:<?php $this->options->title(); ?>

2. 站点URL:<?php $this->options ->siteUrl(); ?>

3. 站点说明:<?php $this->options->description() ?>

4. 站点后台URL:<?php $this->options->adminUrl(); ?>

5. 站点RSS:<?php $this->options->feedUrl(); ?>

6. 站点首页判断:
<?php if ($this->is('index')): ?>
//首页输出内容
<?php else: ?>
//不是首页输出内容
<?php endif; ?>

7. 整站数据统计输出:
<;?php Typecho_Widget::widget('Widget_Stat')->to($stat); ?>
文章总数:<;?php $stat->publishedPostsNum() ?>篇
分类总数:<?php $stat->categoriesNum() ?>个
评论总数:<?php $stat->publishedCommentsNum() ?>条
页面总数:<?php $stat->publishedPagesNum() ?>个
当前作者的文章总数:<?php $stat->myPublishedPostsNum() ?> 篇

二、文章相关

1. 文章或页面的标题:<?php $this->title() ?>
2. 文章或页面的URL:<?php $this->permalink() ?>
3. 文章或页面的发表时间:<?php $this->date(); ?>
4. 文章或页面的访问次数:<?php Views_Plugin::theViews('被访问 ', '次'); ?>
5. 文章上一篇:<?php $this->theNext(); ?>
6. 文章下一篇:<?php $this->thePrev(); ?>
7. 文章分类名:<?php $categorys->name();?>
8. 截取文章摘要,200字数限制:<?php $this->excerpt(200, '.. .'); ?>
9. 作者:<?php $this->author(); ?>
10. 作者的邮箱地址:<?php $this->author->mail(); ?>
11. 文章作者URL:<?php $this->author->url(); ?>
12. 作者全部文章列表URL:<?php $this->author->permalink(); ?>
13. 最后更新:<?php echo date(_mt("Y 年 m 月 d 日 h : i A") , $this->modified + $this->options->timezone - idate("Z"));?>

三、参数说明

  1. 获取已发布的文章数目:publishedPostsNum
  2. 获取待审核的文章数目:waitingPostsNum
  3. 获取草稿文章数目:draftPostsNum
  4. 获取当前用户已发布的文章数目:myPublishedPostsNum
  5. 获取当前用户待审核文章数目:myWaitingPostsNum
  6. 获取当前用户草稿文章数目:myDraftPostsNum
  7. 获取当前用户已发布的文章数目:currentPublishedPostsNum
  8. 获取当前用户待审核文章数目:currentWaitingPostsNum
  9. 获取当前用户草稿文章数目:currentDraftPostsNum
  10. 获取已发布页面数目:publishedPagesNum
  11. 获取草稿页面数目:draftPagesNum
  12. 获取当前显示的评论数目:publishedCommentsNum
  13. 获取当前待审核的评论数目:waitingCommentsNum
  14. 获取当前垃圾评论数目:spamCommentsNum
  15. 获取当前用户显示的评论数目:myPublishedCommentsNum
  16. 获取当前用户显示的评论数目:myWaitingCommentsNum
  17. 获取当前用户显示的评论数目:mySpamCommentsNum
  18. 获取当前文章的评论数目:currentCommentsNum
  19. 获取当前文章显示的评论数目:currentPublishedCommentsNum
  20. 获取当前文章显示的评论数目:currentWaitingCommentsNum
  21. 获取当前文章显示的评论数目:currentSpamCommentsNum
  22. 获取分类数目:categoriesNum

四、其他

1. 页面标题 - 站点名称:<?php $this->archiveTitle('','',' - '); ?><?php $this->options->title(); ?>

2. 主题模板URL:<?php $this->options->themeUrl(); ?>

3. PHP引用:<?php $this->need('*.php'); ?>&emsp;可以使用相对路径获取上级目录php文件

4. 调用自定义字段:<?php $this->fields->fieldName ?>

5. 当前登录用户:<?php $this->user->screenName(); ?>

6. 退出:<a href="<?php $this->options->logoutUrl(); ?>"><?php _e('退出'); ?></a>

7. 完整路径标题:<?php $this->archiveTitle(' &raquo; ', < span class="string">'', ' | '); ?><?php $this ->options->title(); ?>

注:以上可适用于Typecho代码环境:Typecho v1.1 (17.10.30)

五、参考文章

  1. 分享一些Typecho中常用的调用函数-云栖社区-阿里云
  2. 博客程序Typecho主题模版制作常用调用变量和函数,参数分享 - 一极乐
  3. typecho常用的标签函数总结 - 奇乐网 - 草根博客网站

本文标签:typecho代码PHP