typecho评论验证码插件
2022-12-24
分类: typecho
简介:很多用户受到垃圾评论的困扰,因为某些国内服务器无法连接到Akismet服务,所以垃圾评论肆虐。有的用户即使启用了Akismet插件,但成千上万条垃圾评论对服务器负载也造成了影响。因此我开发了一个验证码插件,有需要开发类似插件的用户也可以借鉴一下开发方法。使用方法很简单,下载插件解压后,将其上传至/usr/plugins/目录下,先在后台启用插件,然后编辑摸板,在评论的表单位置也就是comments的form标签之间的任何你认为合适的地方,加上如下代码<p><?php Captcha_Plugin::output(); ?></p>[hide]评论验证码插件.zip[/hide]
Emlog自动为文章标签添加该标签的链接
2021-01-25
分类: Emlog
简介:我们在编写文章时,经常需要添加一些标签的链接,这样不仅可以优化我们的内链,对用户来说也可以参照相关的文章,如果对文章的关键字进行手动添加链接,那样对我们来说太麻烦了,而且在标签关键词很多的情况下我们是记不住的,那怎么如何让Emlog站点的文章自动添加标签链接变为内链呢?其实我们只需要在主题目录下的module.php文件中添加一段代码就可以实现了。打开我们主题的module.php文件添加如下代码: /自动为文章标签添加该标签的链接 function tag_link($content){ global $CACHE; $tag_cache = $CACHE >readCache('tags'); foreach($tag_cache as $value){ $tag_url = Url::tag($value['tagurl']); $keyword = $value['tagname']; $cleankeyword = stripslashes($keyword); $url = "<a href=\"{$tag_url}\" title=\"浏览关于“{$cleankeyword}”的文章\" target=\"_blank\" >{$cleankeyword}</a>"; $regEx = '\'(?!((<.*?)|(<a.*?)))('. $cleankeyword . ')(?!(([^<>]*?)>)|([^>]*?</a>))\'s'; $content = preg_replace($regEx,$url,$content); } return $content; }其次在echo_log.php中将 <?php echo $log_content; ?> 修改成 <?php echo tag_link($log_content); ?> 即可。
typecho评论显示个性化自定义
2020-09-28
分类: typecho
简介:typecho的官方博客有一篇文章专门讲诉typecho的评论自定义显示的,官方的不够直观,方法如下:在 comments.php 开头部份加入如下方法即可实现自定义。(解说可以查看注释)<?php function threadedComments($comments, $singleCommentOptions) { $commentClass = '';
if ($comments >authorId) {
if ($comments >authorId == $comments >ownerId) {
$commentClass .= ' comment by author';
} else {
$commentClass .= ' comment by user';
}
} $commentLevelClass = $comments >_levels > 0 ? ' comment child' : ' comment parent';
?>
<li id="<?php $comments >theId(); ?>" class="comment body<?php
if ($comments >_levels > 0) {
echo ' comment child';
$comments >levelsAlt(' comment level odd', ' comment level even');
} else {
echo ' comment parent';
}
$comments >alt(' comment odd', ' comment even');
echo $commentClass;
//以上部份 不用理会,是判断一些奇偶数评论和作者类的,下面的才是需要修改的,根据需要修改吧, php部份不需要 修改,只需要修改 HTML 部分,下面是我现在用的
?>">
<div class="comment author">
<?php $comments >gravatar($singleCommentOptions >avatarSize, $singleCommentOptions >defaultAvatar); //头像 只输出 img 没有其它标签 ?>
<div class="comment info">
<cite class="fn"><?php $singleCommentOptions >beforeAuthor();
$comments >author();$singleCommentOptions >afterAuthor(); //输出评论者 ?>
</cite>
<em class="comment meta">
<a href="<?php $comments >permalink(); ?>"><?php $singleCommentOptions >beforeDate();
$comments >date($singleCommentOptions >dateFormat);
$singleCommentOptions >afterDate(); //输出评论日期 ?></a>
</em>
</div>
<div class="comment reply">
<?php $comments >reply($singleCommentOptions >replyWord); //输出 回复 链接?>
</div>
</div> <?php $comments >content(); //输出评论内容,包含 <p></p> 标签 ?>
<?php if ($comments >children) { ?>
<div class="comment children">
<?php $comments >threadedComments($singleCommentOptions); //评论嵌套?>
</div>
<?php } ?> </li>
<?php
}
?>下面是对应的CSS代码: - 隐藏 -
Typecho 标签云如何随机展示固定个数的标签
2020-09-16
分类: typecho
简介:官方文档<?php $this >widget('Widget_Metas_Tag_Cloud', 'sort=mid&ignoreZeroCount=1&desc=0&limit=30') >to($tags); ?>
<?php if($tags >have()): ?>
<ul class="tags list">
<?php while ($tags >next()): ?> <li><a href="<?php $tags >permalink(); ?>" rel="tag" class="size <?php $tags >split(5, 10, 20, 30); ?>" title="<?php $tags >count(); ?> 个话题"><?php $tags >name(); ?></a></li>
<?php endwhile; ?>
<?php else: ?> <li><?php _e('没有任何标签'); ?></li>
<?php endif; ?>参数说明sort:排序方式为 mid;ignoreZeroCount:忽略文章数为 0 的;desc:是否降序输出;limit:输出数目。在这里我们可以看到,官方给出的方法,只能固定排序方式和输出个数。而往往标签多了之后,我们使用该方法输出的标签云总是显示这些标签,这时我们想要每次展示的标签都不相同怎么办呢?方法其实很简单,既不用改typecho源码,也不用安装该类插件,只需要把排序方式的值改为rand()即可。$this >widget('Widget_Metas_Tag_Cloud', 'sort=rand()&ignoreZeroCount=1&desc=0&limit=30') >to($tags);