以下typecho调用语法为博主网络收集而来,很多都是很常用的,可方便大家查看调用。如有错误或者问题,也可以在下方留言一起讨论~
站点名称
options->title() ?>
站点网址
options ->siteUrl(); ?>
站点说明
options->description() ?>
文章/页面的作者
author(); ?>
作者头像
< ?php $this->author->gravatar('40') ?>
上下篇调用代码
thePrev(); ?> theNext(); ?>
判断是否为首页,输出相关内容
is('index')): ?>//是首页输出内容
//不是首页输出内容
文章/页面评论数目 commentsNum('No Comments', '1 Comment' , '%d Comments'); ?>
截取文章内容显示摘要(350是字符数)
excerpt(350, '.. .'); ?>
调用自定义字段
fields->fieldName ?>
RSS地址
options->feedUrl(); ?>
获取最新评论列表
- widget('Widget_Comments_Recent')->to($comments); ?> next()): ?>
- https://www.veimoz.com/author(false); ?>: https://www.veimoz.com/excerpt(50, '...'); ?>
分类名称(无链接)
category(',', false); ?>
获取文章时间归档
- widget('Widget_Contents_Post_Date', 'type=month&format=F Y') ->parse('
- {date} '); ?>
获取标签集合
widget('Widget_Metas_Tag_Cloud', 'ignoreZeroCount=1&limit=28')->to($tags); ?>next()): ?>https://www.veimoz.com/name(); ?>
登陆与未登录用户展示不同内容
user->hasLogin()): ?>//登陆可见
//未登录和登陆均可见
自动调用img字段内容,如果没有,去文章搜索第1个图片。
___fields()))): ?>fields->img(); ?>]*>/i", $this->content, $matches);
$imgCount = count($matches[0]);
if($imgCount >= 1){
$img = $matches[2][0];
echo <<
文章内容替换七牛网址
content); ?>
文章字数统计
在functions.php中写入代码:
function art_count ($cid){
$db=Typecho_Db::get ();
$rs=$db->fetchRow ($db->select ('table.contents.text')->from ('table.contents')->where ('table.contents.cid=?',$cid)->order ('table.contents.cid',Typecho_Db::SORT_ASC)->limit (1));
echo mb_strlen($rs['text'], 'UTF-8');
}
在模板中调用:
cid); ?>
自动调用第1个文章图片
]*>/i", $this->content, $matches);
$imgCount = count($matches[0]);
if($imgCount >= 1){
$img = $matches[2][0];
echo <<
Html;
}
?>
边栏不显示博主评论
widget('Widget_Comments_Recent','ignoreAuthor=true')->to($comments); ?>
前台登录表单
......
当然,应该还有很多的调用语法没有收集到,也欢迎大家补充和修正,谢谢。
!
发表评论