Typecho 主题模版制作常用调用变量和函数,参数分享

时间:2020-08-01   阅读:610

Typecho 主题模版制作常用调用变量和函数,参数分享


博主对Typecho博客程序情有独钟,但是还不会PHP所以四处收集Typecho制作模板的代码和函数什么的。
一个是方便自己使用,另外一个方便大家查看,又找到了点代码,今天发一下。

站点名称


<?php $this->options->title(); ?>


域名地址


<?php $this->options->siteUrl(); ?>


后台地址


<?php $this->options->adminUrl(); ?>


完整路径标题,比如 文章 站点


<?php $this->archiveTitle(' &raquo; ', '', ' - '); ?&gt;&lt;?php $this->options->title(); ?>


站点说明


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


模版文件夹地址


<?php $this->options->themeUrl(); ?>


作者名字


<?php $this->author(); ?>


当前登陆用户名字


<?php $this->user->screenName(); ?>


退出链接


options->logoutUrl(); ?>" target="_blank" _href="http://t.160.me/options->logoutUrl(); ?>">


rss地址


options->logoutUrl(); ?>" target="_blank" _href="http://t.160.me/options->logoutUrl(); ?>">
<?php $this->options->feedUrl(); ?>


作者头像


options->logoutUrl(); ?>" target="_blank" _href="http://t.160.me/options->logoutUrl(); ?>">
<?php $this->author->gravatar('200') ?>


参数说明

此函数是完整 img 标签,200代表长和宽

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


options->logoutUrl(); ?>" target="_blank" _href="http://t.160.me/options->logoutUrl(); ?>">
<?php $this->author->permalink(); ?>


该文作者个人主页链接


options->logoutUrl(); ?>" target="_blank" _href="http://t.160.me/options->logoutUrl(); ?>">
<?php $this->author->url(); ?>


该文作者的邮箱地址


options->logoutUrl(); ?>" target="_blank" _href="http://t.160.me/options->logoutUrl(); ?>">
<?php $this->author->mail(); ?>


rss评论


options->logoutUrl(); ?>" target="_blank" _href="http://t.160.me/options->logoutUrl(); ?>">
<?php $this->options->commentsFeedUrl(); ?>


引用模版文件夹内php文件


options->logoutUrl(); ?>" target="_blank" _href="http://t.160.me/options->logoutUrl(); ?>">
<?php $this->need('*.php'); ?>


参数说明

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

获取最新post


options->logoutUrl(); ?>" target="_blank" _href="http://t.160.me/options->logoutUrl(); ?>">
<?php $this->widget('Widget_Contents_Post_Recent', 'pageSize=8&type=category')->parse('<li>{title}</li>'); ?>


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


<?php $this->category(',', false); ?>


获取文章分类列表


 
 
 
 
  • <?php $this->widget('Widget_Metas_Category_List')                ->parse('

  • {name} ({count})

  • '); ?>

获取某分类post


  
  
  
  
  • <?php $this->widget('[email protected]', 'pageSize=8&type=category', 'mid=1') ->parse('

  • {title}

  • '); ?>

获取最新评论列表


   
   <?php $this->widget('Widget_Comments_Recent')->to($comments); ?>
            <?php while($comments->next()): ?>permalink(); ?>"><?php $comments->author(false); ?>: excerpt(50, '...'); ?>首页获取 最新文章 代码限制条数 (特别感谢蚂蚱)permalink(); ?>"><?php $comments->author(false); ?>: excerpt(50, '...'); ?>首页获取 最新文章 代码限制条数 (特别感谢蚂蚱) <?php while ($this->next()): ?> <?php if ($this->sequence <= 3): ?> html <?php endif; ?> <?php endwhile; ?>

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


<?php $this->widget('Widget_Comments_Recent','ignoreAuthor=true')->to($comments); ?>
    <?php while($comments->next()): ?>
    <li>

上一篇:Typecho N天内评论最多的文章

下一篇:Typecho 实现短代码功能。

网友评论