Typecho博客中常用的调用函数

YunAdmin
2024-03-26 / 4 评论 / 176 阅读 / 正在检测是否收录...

一、站点相关

  1. 站点名称:

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

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

    <?php $this->options->description() ?>

4.站点后台URL:

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

    <?php $this->options->feedUrl(); ?>
  2. 站点首页判断:

    <?php if ($this->is('index')): ?>

    首页输出内容

    <?php else: ?>

    不是首页输出内容

    <?php endif; ?>
  3. 整站数据统计输出:

    <;?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"));?>

三、参数说明

获取已发布的文章数目:publishedPostsNum
获取待审核的文章数目:waitingPostsNum
获取草稿文章数目:draftPostsNum
获取当前用户已发布的文章数目:myPublishedPostsNum
获取当前用户待审核文章数目:myWaitingPostsNum
获取当前用户草稿文章数目:myDraftPostsNum
获取当前用户已发布的文章数目:currentPublishedPostsNum
获取当前用户待审核文章数目:currentWaitingPostsNum
获取当前用户草稿文章数目:currentDraftPostsNum
获取已发布页面数目:publishedPagesNum
获取草稿页面数目:draftPagesNum
获取当前显示的评论数目:publishedCommentsNum
获取当前待审核的评论数目:waitingCommentsNum
获取当前垃圾评论数目:spamCommentsNum
获取当前用户显示的评论数目:myPublishedCommentsNum
获取当前用户显示的评论数目:myWaitingCommentsNum
获取当前用户显示的评论数目:mySpamCommentsNum
获取当前文章的评论数目:currentCommentsNum
获取当前文章显示的评论数目:currentPublishedCommentsNum
获取当前文章显示的评论数目:currentWaitingCommentsNum
获取当前文章显示的评论数目:currentSpamCommentsNum
获取分类数目:categoriesNum

四、其他

  1. 页面标题 - 站点名称:

    <?php $this->archiveTitle('','',' - '); ?><?php $this->options->title(); ?>
  2. 主题模板URL:

    <?php $this->options->themeUrl(); ?>
  3. PHP引用:

    <?php $this->need('*.php'); ?>&emsp;

    可以使用相对路径获取上级目录php文件

  1. 调用自定义字段:

    <?php $this->fields->fieldName ?>
  2. 当前登录用户:

    <?php $this->user->screenName(); ?>
  3. 退出:
<a href="<?php $this->options->logoutUrl(); ?>">
<?php _e('退出'); ?>
</a>
  1. 完整路径标题:

    <?php $this->archiveTitle(' &raquo; ', < span class="string">'', ' | '); ?><?php $this ->options->title(); ?>
0

评论 (4)

取消
  1. 头像
    pdhhgtgtgt
    Windows 10 · Google Chrome

    文章中的实用建议和操作指南,让读者受益匪浅,值得珍藏。

    回复
  2. 头像
    zadcqrjhmf
    Windows 10 · Google Chrome

    多语种文献的引用彰显学术包容性。

    回复
  3. 头像
    tudilbdhtx
    Windows 10 · Google Chrome

    ?叙事类评语?

    回复
  4. 头像
    fmaqugoksh
    Windows 10 · Google Chrome

    作者对主题的挖掘深入骨髓,展现了非凡的洞察力和理解力。

    回复