admin

Typecho实现回复可见功能
先在post.php中添加以下代码 <?php $db = Typecho_Db::get()...
扫描右侧二维码阅读全文
30
2018/07

Typecho实现回复可见功能

先在post.php中添加以下代码

    <?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-&gt;user-&gt;hasLogin() || $result) {
    $content = preg_replace("/\[hide\](.*?)\[\/hide\]/sm",'&lt;div&gt;&lt;i&gt;&lt;/i&gt;$1</div>',$this->content);
    }
    else{
    $content = preg_replace("/\[hide\](.*?)\[\/hide\]/sm",'&lt;div&gt;&lt;i&gt;&lt;/i&gt;此处内容需要评论回复后方可阅读。&lt;/div&gt;',$this->content);
    }
    echo $content
    ?>

用以上代码替换以下代码

    <?php $this->content(''); ?>

修改完毕后在文中使用[hide]标签就实现了内容回复可见功能.

代码来源:清楼小筑

Last modification:July 30th, 2018 at 10:42 pm
If you think my article is useful to you, please feel free to appreciate

2 comments

  1. 芭比

    这个我也在用着

    1. admin

Leave a Comment