首页
反馈
朋友
统计
更多
投稿
推荐
毒鸡汤
Search
1
主题 添加author page
7,980 阅读
2
主题移动端,样式下添加二级分类
7,964 阅读
3
主题添加移动端下边栏
7,914 阅读
4
EMlog添加评论者邮箱等级
5,344 阅读
5
Emlog模版文章页标题自动变颜色方法
5,279 阅读
typecho
dynamic
SuiYu
Emlog
xiuno
登录
Search
标签搜索
代码
xiuno
typecho
css
评论
say
php
模板
修改教程
js
recommend
善良
标签
珍惜
语法高亮
苦
惜
洒脱
认证
评论时间
emlly
累计撰写
133
篇文章
累计收到
140
条评论
首页
栏目
typecho
dynamic
SuiYu
Emlog
xiuno
页面
反馈
朋友
统计
投稿
推荐
毒鸡汤
搜索到
1
篇与
回复可见
的结果
2020-07-26
Typecho完美实现回复可见功能
将post.php中的<?php $this->content(); ?>换成<?php $db = Typecho_Db::get(); $sql = $db->select()->from('table.comments') ->where('cid = ?',$this->cid) ->where('mail = ?', $this->remember('mail',true)) ->limit(1); $result = $db->fetchAll($sql); if($this->user->hasLogin() || $result) { $content = preg_replace("/\[hide\](.*?)\[\/hide\]/sm",'<div class="reply2view">$1</div>',$this->content); } else{ $content = preg_replace("/\[hide\](.*?)\[\/hide\]/sm",'<div class="reply2view">此处内容需要评论回复后方可阅读。</div>',$this->content); } echo $content ?>解决缩略内容和feed暴露问题。在functions.php中加入如下代码即可Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx = array('myyodux','one'); Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('myyodux','one'); class myyodux { public static function one($con,$obj,$text) { $text = empty($text)?$con:$text; if(!$obj->is('single')){ $text = preg_replace("/\[hide\](.*?)\[\/hide\]/sm",'',$text); } return $text; } }就是用插件接口,在缩略内容输出之前,隐藏掉或者替换掉回复可见内容,同时使用if判断,来针对非single页面进行隐藏。使用方法:在写文章需要隐藏部分内容时用以下写法(去掉@)[@hide]要隐藏的内容[/hide]CSS参考样式.reply2view { background:#f8f8f8; padding:10px 10px 10px 40px; position:relative }结语这个新方法实现评论回复可见,来自泽泽博客
2020年07月26日
693 阅读
1 评论
1 点赞