typecho使用的代码,很多都是锚点,钩子函数使用起来很方便,分享一些常用的代码
1.标题类
【博客首页】博客名称
【独立页面】页面标题 - 博客名称
【分类页面】分类名称 - 博客名称
【标签页面】Tag: 标签 - 博客名称
【存档页面】存档: XXXX年XX月 - 博客名称
【其它(日志页)】页面标题
<title>
<?php if ($this->is('index')){$this->options->title();}
elseif($this->is('page')){$this->archiveTitle('','',' - ');$this->options->title();}
elseif($this->is('category')){$this->archiveTitle('','',' - ');$this->options->title();}
elseif($this->is('tag')){$this->archiveTitle('','Tag: ',' - ');$this->options->title();}
elseif($this->is('archive')){$this->archiveTitle('年','存档: ','月 - ');$this->options->title();}
else{$this->archiveTitle('','','');}?>
</title>
2.输出标签词
输出所有(最好把它用在单独页面中):
<?php $this->widget('Widget_Metas_Tag_Cloud') ->parse('<span class="tagcloud"><a href="{permalink}">{name}</span></a>'); ?>
(使用于边栏)
<?php $this->widget('Widget_Metas_Tag_Cloud', array('sort' => 'count', 'ignoreZeroCount' => true, 'desc' => true, 'limit' => 20))->to($tags); ?>
<?php while($tags->next()): ?>
<li>
<a rel="tag" href="<?php $tags->permalink(); ?>" ><?php $tags->name(); ?></a>
</li>
<?php endwhile; ?>
<?php $this->widget('Widget_Contents_Post_Date', 'type=month&format=Y年m月')
->parse('<li><a href="{permalink}">{date}</a> <span id="ignore">({count})</span></li>'); ?>
4、标签云
<?php $this->widget('Widget_Metas_Tag_Cloud', ignoreZeroCount=1&limit=20′)->to($tags); ?>
<?php while($tags->next()): ?>
<a href=”<?php $tags->permalink(); ?>”><?php $tags->name(); ?></a>
<?php endwhile; ?>
5.头部标签
<?php $this->keywords('_'); ?> //关键词
<?php $this->options->title(); ?> //站点名称
<?php $this->options->description(); ?> //站点描述
<?php $this->archiveTitle(); ?> //标题
<?php $this->options->themeUrl('ie.css'); ?> //模板路径
<?php $this->options->siteUrl(); ?> //主页网址
<?php $this->options->feedUrl(); ?>
<?php $this->options->commentsFeedUrl(); ?>
<?php $this->pageNav(); ?> //分页
<?php $this->options->generator(); ?> //版本号
6.文章页参数
<?php $this->title(); ?> //标题
<?php $this->category(','); ?> //分类
<?php $this->tags(', ', true, ''); ?> //标签
<?php $this->date('F jS, Y') ?> //时间
<?php $this->content(); ?> //内容
<?php $this->thePrev('« %s', ''); ?> //上一篇
<?php $this->theNext('%s »', ''); ?> //下一篇
<?php $this->widget('Widget_Archive@index', 'pageSize=6&type=category', 'mid=1')
->parse('<li><a href="{permalink}">{title}</a></li>'); ?>
8.侧边栏评论忽略博主评论
<?php $this->widget('Widget_Comments_Recent','ignoreAuthor=true')->to($comments); ?>
9.评论输出
<?php $comments->author(true); ?>//输出评论人昵称,参数true为带链接的,false为不带链接的;
//ps.其实还有一个参数,类型也是布尔,作用是是否带noFollow
<?php $comments->excerpt(18, '...'); ?>//输出评论摘要,第一个参数是要截取的长度,第二个是截取后的字符串;
<?php $comments->permalink(); ?>//获取当前评论链接,木有参数;
<?php $comments->title(); ?>//获取当前评论标题,同样木有参数;
<?php $comments->dateWord(); ?>//输出词义化日期,就是输出“3小时前”、“三天前”之内的;
<?php $comments->gravatar(); ?>//调用gravatar输出用户头像,有两个参数,第一个是头像尺寸,默认是32,第二个是默认输出的头像。
如出现错误,或者没有添加的,请在底部留言