让EMLOG评论框支持UBB代码的方法
EMLOG原生模板的评论框只支持文字等评论方式,看起来比较单调,市面上部分模板同样也是如此,而作为HTML的一个变种,UBB代码则可以满足插入图片、插入链接、字体加粗等等多元化的评论需求,现在就来为大家分享一个让EMLOG评论框支持UBB代码的方法。
一、操作步骤
1、下载模板文件module.php,在适当的位置加入以下代码
<?php /** * 评论多功能UBB * @param [type] $comment [description] * @return [type] [description] */ function contentUBB($comment){ return $comment = preg_replace( array( '/\[b\](.*?)\[\/b\]/is', '/\[i\](.*?)\[\/i\]/is', '/\[u\](.*?)\[\/u\]/is', '/\[del\](.*?)\[\/del\]/is', '/\[color=([\w|#]*?)\](.*?)\[\/color\]/is', '/\[url=([^\"\']+)\](.*?)\[\/url\]/is', '/\[img\]([^\"\'\]\[]+)\[\/img\]/is' ), array( '<b class="comment-t-b">$1</b>', '<i class="comment-t-i">$1</i>', '<u class="comment-t-u">$1</u>', '<del class="comment-t-del">$1</del>', '<span style="color: $1" class="comment-t-color">$2</span>', '<a href="go.php?url=$1" target="_blank" class="comment-t-a links" rel="nofollow noopener">$2</a>', '<a href="$1" target="_blank" title="$1" class="comment-img"><i class="fa fa-file-image-o"></i> 查看图片</a>' ), $comment ); } ?>
2、将module.php文件中所有的$comment['content']全部替换成contentUBB($comment['content'])
3、上传覆盖
二、注意事项
1、如果无法找到$comment['content'],则可能是该模板开发者使用的留言输出变量名不同,您可以在评论列表与子评论列表中找到输出留言的变量,套上contentUBB(),当然,为了稳妥起见建议您联系该模板开发者。