域名不卖,勿扰!

Emlog内容登录可见

原理很简单,只需要判断一下是不是游客就可以了。

1.打开主题的module.php文件添加以下代码:

function slyc($content) {
if (preg_match_all(‘/<dl\>([\s\S]*?)<\/dl\>/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;
}

2.将echo_log.php文件中的 <?php echo $log_content; ?>替换为<?php echo slyc($log_content); ?>
使用方法:

在编辑文章需要隐藏内容的时候,切换至html模式,将要隐藏的内容放在<dl></dl>之间。

列如:           <dl>这里添加你要隐藏的内容.</dl>

版权共享,随意转载:云破天开 » Emlog内容登录可见