AJAX - demo
2017-05-04 •
评论
请在下面的输入框中输入字母 A - Z
在 function.php
文件中添加代码
function random_str() {
$poems="Hello World
已知花意,未见其花,已见其花,未闻花名
如果能不长大就好了啊,可是时光在身后挡住退路
或许前路永夜,即便如此我也要前进,因为星光即使微弱也会为我照亮前路
你驻足于春色中,于那独一无二的春色之中
生活是不公平的,要去适应它";
$poems=explode("\n",$poems);
return $poems[rand(0,count($poems)-1)];
}
function says(){
$says=random_str();
echo $says;
}
修改 Comments.php
文件
文件所在位置 /var/Widget/Abstract/Comments.php
修改代码(约第 376
行)
//echo '<a href="' , $this->url , '"' , ($noFollow ? ' rel="external nofollow"' : NULL) , '>' , $this->author , '</a>';//原代码
echo '<a href="' , $this->url , '"' , ($noFollow ? ' rel="external nofollow"' : NULL) , ' target="_blank" ' ,'>' , $this->author , '</a>';//添加_blank属性
将以下代码插入到主题中的 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));
$text = preg_replace("/[^\x{4e00}-\x{9fa5}]/u", "", $rs['text']);
echo mb_strlen($text,'UTF-8');
}
php
代码
<?php $stat = Typecho_Widget::widget('Widget_Stat'); ?>
<?php echo $stat->categoriesNum; ?>个分类
<?php echo $stat->publishedPagesNum; ?>个页面
<?php echo $stat->PublishedPostsNum; ?>篇文章
<?php echo $stat->publishedCommentsNum; ?>条评论
<?php
//分类及对应的文章数
$this->widget('Widget_Metas_Category_List')->parse('<a href="{permalink}">{name}({count})</a>');
?>
<?php
//标签及对应的文章数
$this->widget('Widget_Metas_Tag_Cloud')->parse('<a href="{permalink}">{name}({count})</a>');
?>
参考自 吕滔博客
代码
<?php
echo gmdate('Y-m-d H:i:s',
$this->modified + Typecho_Widget::widget('Widget_Options')->timezone);
?>