请注意,本文编写于 314 天前,最后修改于 306 天前,其中某些信息可能已经过时。
post.php文件
这里我们是依照Cuckoo模板来修改的,大家可以根据自己的情况来修改。
//找到
<?php $modified = intval((time() - $this->modified) / 86400);
$created = intval((time() - $this->created) / 86400);
if($modified > 30){echo "<div class='warning'><blockquote>请注意,本文编写于 $created 天前,最后修改于 $modified 天前,其中某些信息可能已经过时。</blockquote></div>";}
echo parseBiaoQing(parseContent($this->content)); ?>
//修改成
<?php $modified = intval((time() - $this->modified) / 86400);
$created = intval((time() - $this->created) / 86400);
if($modified > 30){echo "<div class='warning'><blockquote>请注意,本文编写于 $created 天前,最后修改于 $modified 天前,其中某些信息可能已经过时。</blockquote></div>";}
echo parse_content(parseBiaoQing(parseContent($this->content)),$this->cid,$this->remember('mail',true),$this->user->hasLogin()); ?>
其他的模板应该是
//找到
<?php $this->content(); ?>
//修改为
<?php echo parse_content($this->content,$this->cid,$this->remember('mail',true),$this->user->hasLogin()); ?>
functions.php文件
function parse_content($content,$cid,$mail,$login){
$db = Typecho_Db::get();
$sql = $db->select()->from('table.comments')
->where('cid = ?',$cid)
->where('mail = ?', $mail)
->where('status = ?', 'approved')
->limit(1);
$result = $db->fetchAll($sql);
if($login || $result) {
$content = preg_replace("/\[hide\](.*?)\[\/hide\]/sm",'$1',$content);
}
else{
$content = preg_replace("/\[hide\](.*?)\[\/hide\]/sm",'<div class="reply2view">您需要<a href="/admin/login.php">登录</a>或者<a onclick="window.scrollTo(0, document.documentElement.clientHeight);">回复</a>才能显示此处隐藏内容。</div>',$content);
}
return $content;
}
Typecho_Plugin::factory('Widget_Abstract_Contents')->excerptEx = array('moleft','one');
Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = array('moleft','one');
class moleft {
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;
}
}
header.php文件
<!-- 在head标签中添加回复可见的样式 -->
<style>
.reply2view {
background:#f8f8f8;
border-radius:5px;
border:1px dashed #888888;
padding:10px 10px 10px 40px;
position:relative;
}
</style>
<!-- 带有半透明效果的样式 -->
<style>
.reply2view {
background-color:rgb(255,255,255,0.3);
border-radius:5px;
border:1px dashed #888888;
padding:10px 10px 10px 40px;
position:relative;
}
</style>
加@是防止被替换成隐藏内容
[@hide]要隐藏的内容[/hide]
版权属于:Rileysion's Blog
本文链接:https://www.zyysvip.cn/148.html
转载时须注明出处及本声明
全部评论 (暂无评论)
info 还没有任何评论,你来说两句呐!