记录学习与后端知识并分享学习代码过程(会飞的鱼Blog)

Emlog文章隐藏内容登陆后可见

会飞的鱼 0 2011 2017年9月29日

首先在模板module.php中增加已下代码:

function login_to_view($content){
        if (preg_match_all('/<!--loginview start-->([\s\S]*?)<!--loginview end-->/i', $content, $hide_words)){
                if( ISLOGIN ){
                        $content = str_replace($hide_words[0], $hide_words[1], $content);
                }else{
                        $hide_notice = '<div style="text-align:center;border:1px dashed #FF9A9A;padding:8px;margin:10px auto;color:#FF6666;">您必须先<a href="'.BLOG_URL.'admin">登录</a>才能查看隐藏内容</div>';
                        $content = str_replace($hide_words[0], $hide_notice, $content);
                }
        }
        return $content;
}

其次将模板echo_log.php中$log_content修改成login_to_view($log_content);即可,最后就是后台了。

使用方式:

在后台编辑文章的时候,切换到HTML模式添加:<!--loginview start-->要隐藏的内容<!--loginview end-->

本文由 @会飞的鱼 于 2017-9-29 发布在 会飞的鱼Blog,如无特别说明,本博文章均为原创,转载请保留出处。

网友评论

    暂无评论

会飞的鱼 V

一条会飞的鱼!

745 文章
7274 评论
1070 万 阅读
8年 博龄
最新文章
最新评论
嘻嘻嘻
1个月前 (2024-03-19)

ThinkPHP实现用户注册、登录模块

标签

会飞的鱼 在线咨询

在线时间:9:00-22:00
周六、周日:14:00-22:00