DedeCMS会员等级信息是通过rank值判断的,可以在后台-会员管理-会员级别设置,看到级别名称和对应的会员等级值。我们能直接调用的是会员等级值,而不是会员级别名称。自己动手写个php判断,下面结合ajax实现在前台任意位置、会员中心相关页面调用会员级别名称和其他相关值。
在模板头部head.htm增加代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
<style>
.pr{float:right;}
.pl{float:left;}
</style>
<divclass="pr">
<spanid="_userlogin"class="pr"><!--不能更换id,里面的所有内容在用户登陆后回被替换掉-->
<span>游客</span>
<ahref="{dede:global.cfg_basehost/}{dede:global.cfg_memberurl/}/login.php"style="border-left:0">登录</a>
<ahref="{dede:global.cfg_basehost/}{dede:global.cfg_memberurl/}/index_do.php?fmdo=user&dopost=regnew">注册</a>
<scriptlanguage="javascript"type="text/javascript">CheckLogin();</script>
</span>
<spanclass="pl"><!--问候语js放在<divid="_userlogin">外面不然会被替换掉,也不能放在ajax里面,里面会失效-->
<scripttype="text/javascript">
varnow=(newDate()).getHours();
if(now>0&&now<=6){
document.write("午夜好,");
}elseif(now>6&&now<=11){
document.write("早上好,");
}elseif(now>11&&now<=14){
document.write("中午好,");
}elseif(now>14&&now<=18){
document.write("下午好,");
}else{
document.write("晚上好,");
}
</script>
</span>
</div><!--/pr-->
|
对应的模板要引入ajax,把下面代码放在</head>前。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<scriptlanguage="javascript"type="text/javascript"src="{dede:global.cfg_cmsurl/}/include/dedeajax2.js"></script>
<scriptlanguage="javascript"type="text/javascript">
<!--
$(function(){
$("a[_for]").mouseover(function(){
$(this).parents().children("a[_for]").removeClass("thisclass").parents().children("dd").hide();
$(this).addClass("thisclass").blur();
$("#"+$(this).attr("_for")).show();
});
$("a[_for=uc_member]").mouseover();
$("a[_for=flink_1]").mouseover();
});
functionCheckLogin(){
vartaget_obj=document.getElementById('_userlogin');
myajax=newDedeAjax(taget_obj,false,false,'','','');
myajax.SendGet2("{dede:global.cfg_cmspath/}/member/ajax_loginsta.php");
DedeXHTTP=null;
}
-->
</script>
|
模板增加内容完毕,打开/member/ajax_loginsta.php,这部分内容就是替换<div id=_userlogin></div>包含的所有内容,根据需要修改即可。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<divclass="userinfo">
<?phpecho$cfg_ml->M_UserName;?><!--用户名-->
<imgsrc="<?phpecho$facepic;?>"width="30"height="30"/><!--用户头像-->
<p>
<?php
if($cfg_ml->M_Rank=='180'){
echo"认证会员<imgsrc='/images/v.png'width='20'height='20'alt='已加V认证'>";}
elseif($cfg_ml->M_Rank=='20'){
echo"初级会员";}
elseif($cfg_ml->M_Rank=='10'){
echo"注册会员";}
?>
</p><!--会员级别值分别为180、20、10,根据实际情况自行修改-->
</div>
|
免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)