为你的Emlog博客评论区添加评论者等级,评论者的等级由评论者的邮箱的次数来分配等级,等级可以自行设置。
1、模版/module.php文件增加以下代码:
<?php //评论者等级 function echo_levels($comment_author_email,$comment_author_url){ $DB = Database::getInstance(); global $CACHE; $user_cache = $CACHE->readCache('user'); $adminEmail = '"'.$user_cache[1]['mail'].'"'; if($comment_author_email==$adminEmail){ echo '<a class="admin" title="管理员"><img src="'.TEMPLATE_URL.'images/admin.png"></a>'; } $sql = "SELECT cid as author_count,mail FROM ".DB_PREFIX."comment WHERE mail != '' and mail = $comment_author_email and hide ='n'"; $res = $DB->query($sql); $author_count = $DB->num_rows($res); if($author_count>=0 && $author_count<5 && $comment_author_email!=$adminEmail) echo '<a class="vip1" title="VIP等级:初入联盟 LV.1"><i class="pro"></i><i class="level">Lv.1</i></a>'; else if($author_count>=5 && $author_count<10 && $comment_author_email!=$adminEmail) echo '<a class="vip2" title="VIP等级:英勇黄铜 LV.2"><i class="pro"></i><i class="level">Lv.2</i></a>'; else if($author_count>=10 && $author_count<20 && $comment_author_email!=$adminEmail) echo '<a class="vip3" title="VIP等级:不屈白银 LV.3"><i class="pro"></i><i class="level">Lv.3</i></a>'; else if($author_count>=20 && $author_count<30 && $comment_author_email!=$adminEmail) echo '<a class="vip4" title="VIP等级:华贵铂金 LV.4"><i class="pro"></i><i class="level">Lv.4</i></a>'; else if($author_count>=30 &&$author_count<40 && $comment_author_email!=$adminEmail) echo '<a class="vip5" title="VIP等级:璀璨钻石 LV.5"><i class="pro"></i><i class="level">Lv.5</i></a>'; else if($author_count>=40 && $author_coun<50 && $comment_author_email!=$adminEmail) echo '<a class="vip6" title="VIP等级:超凡大师 LV.6"><i class="pro"></i><i class="level">Lv.6</i></a>'; else if($author_count>=50 && $author_coun<60 && $comment_author_email!=$adminEmail) echo '<a class="vip7" title="VIP等级:最强王者 LV.7"><i class="pro"></i><i class="level">Lv.7</i></a>'; else if($author_count>=60 && $author_coun<70 && $comment_author_email!=$adminEmail) echo '<a class="vip8" title="VIP等级:职业选手 LV.8"><i class="pro"></i><i class="level">Lv.8</i></a>'; } ?>
2、在module.php文件里,评论等级显示位置增加以下代码:
<span class="comment-reply"><?php echo echo_levels("\"".strip_tags($comment['mail'])."\"","\"".$isuserlink."\"");?></span>
3、等级颜色css代码:
/*评论等级*/ .vip1 {margin-left: 1px;font-size: 12px;color: #fff;background-color: #348be8;padding: 0 4px;border-radius: 2px;font-size: 12px;cursor: pointer;-webkit-transition: .3s;-khtml-opacity: .5;opacity: .5;line-height: 150%;display: inline-block;vertical-align: middle;} .vip2 {margin-left: 1px;font-size: 12px;color: #fff;background-color: #0bf;padding: 0 4px;border-radius: 2px;font-size: 12px;cursor: pointer;-webkit-transition: .3s;-khtml-opacity: .5;opacity: .5;line-height: 150%;display: inline-block;vertical-align: middle;} .vip3 {margin-left: 1px;font-size: 12px;color: #fff;background-color: #fd8edb;padding: 0 4px;border-radius: 2px;font-size: 12px;cursor: pointer;-webkit-transition: .3s;-khtml-opacity: .5;opacity: .5;line-height: 150%;display: inline-block;vertical-align: middle;} .vip4 {margin-left: 1px;font-size: 12px;color: #fff;background-color: #eb5055;padding: 0 4px;border-radius: 2px;font-size: 12px;cursor: pointer;-webkit-transition: .3s;-khtml-opacity: .5;opacity: .5;line-height: 150%;display: inline-block;vertical-align: middle;} .vip5 {margin-left: 1px;font-size: 12px;color: #fff;background-color: #6f8ec5;padding: 0 4px;border-radius: 2px;font-size: 12px;cursor: pointer;-webkit-transition: .3s;-khtml-opacity: .5;opacity: .5;line-height: 150%;display: inline-block;vertical-align: middle;} .vip6 {margin-left: 1px;font-size: 12px;color: #fff;background-color: #5fb878;padding: 0 4px;border-radius: 2px;font-size: 12px;cursor: pointer;-webkit-transition: .3s;-khtml-opacity: .5;opacity: .5;line-height: 150%;display: inline-block;vertical-align: middle;} .vip7 {margin-left: 1px;font-size: 12px;color: #fff;background-color: #c0c000;padding: 0 4px;border-radius: 2px;font-size: 12px;cursor: pointer;-webkit-transition: .3s;-khtml-opacity: .5;opacity: .5;line-height: 150%;display: inline-block;vertical-align: middle;} .vip8 {margin-left: 1px;font-size: 12px;color: #fff;background-color: #292929;padding: 0 4px;border-radius: 2px;font-size: 12px;cursor: pointer;-webkit-transition: .3s;-khtml-opacity: .5;opacity: .5;line-height: 150%;display: inline-block;vertical-align: middle;}
第二种方法:直接下载插件导入激活使用。
下载地址
官网下载
本文共 171 个字数,平均阅读时长 ≈ 1分钟
评论 (0)