在用帝国cms7.5做网站的时候会在网站首页添加会员登录框,当用户登录完成后,会显示登录用户的信息,但是帝国CMS提供的loginjs.php文件中并没有调用会员头像的方法,下面主要为大家介绍在登录状态模板中调用会员头像的方法:
首先打开文件:/e/member/login/loginjs.php,找到如下代码:
$r = $empire ->fetch1( "select " .eReturnSelectMemberF( 'userid,username,groupid,userfen,money,userdate,havemsg,checked' ). " from " .eReturnMemberTable(). " where " .egetmf( 'userid' ). "='$myuserid' and " .egetmf( 'rnd' ). "='$myrnd' limit 1" ); |
在下面添加如下代码:
$userr = $empire ->fetch1( "select userpic from phome_enewsmemberadd where userid='$r[userid]'" ); |
注意将表前缀phome_改成自己的。
然后在需要调用头像的地方使用下面的代码调用头像:
<img src= "" > |
如果会员未上传头像,则用一张默认图片代替:
<img src= "" > |
以上方法经过验证,貌似不好用
以下方法,经杨青青小姐姐测试过,好用:
打开e/data/template/loginiframetemp.txt
在$r=$empire->fetch1("select ".$user_userid.",".$user_username.",".$user_group.",".$user_userfen.",".$user_money.",".$user_userdate.",".$user_havemsg.",".$user_checked." from ".$user_tablename." where ".$user_userid."='$myuserid' and ".$user_rnd."='$myrnd' limit 1");下面 添加 $m=$empire->fetch1("select userpic from {$user_tbpre}enewsmemberadd where userid='$myuserid' limit 1"); $userpic=$m['userpic']?$m['userpic']:$public_r[newsurl].'e/data/images/nouserpic.gif'; |
在登录状态模板中使用<?=$userpic?>调用会员头像
--------------------备注----
文件:e/member/login/login.js
查找 $r=$empire->fetch1("select,注意修改前缀
1 2 3 4 5 6 7 8 |
$r = $empire ->fetch1( "select " .eReturnSelectMemberF( 'userid,username,groupid,userfen,money,userdate,havemsg,checked' ). " from " .eReturnMemberTable(). " where " .egetmf( 'userid' ). "='$myuserid' and " .egetmf( 'rnd' ). "='$myrnd' limit 1" ); $m = $empire ->fetch1( "select userpic from hehua_enewsmemberadd where userid='$myuserid' limit 1" ); $userpic = $m [ 'userpic' ]? $m [ 'userpic' ]: $public_r [newsurl]. 'e/data/images/nouserpic.gif' ; if ( empty ( $r [userid])|| $r [checked]==0) { EmptyEcmsCookie(); $mhavelogin =0; } |
以上文件,一刷新缓存,改了的文件也会白改,所以,还需要在另外一个地方修改文件:
打开e/data/template/loginiframetemp.txt
在$r=$empire->fetch1("select
1 2 3 4 5 6 7 8 |
$r = $empire ->fetch1( "select " .eReturnSelectMemberF( 'userid,username,groupid,userfen,money,userdate,havemsg,checked' ). " from " .eReturnMemberTable(). " where " .egetmf( 'userid' ). "='$myuserid' and " .egetmf( 'rnd' ). "='$myrnd' limit 1" ); $m = $empire ->fetch1( "select userpic from hehua_enewsmemberadd where userid='$myuserid' limit 1" ); $userpic = $m [ 'userpic' ]? $m [ 'userpic' ]: $public_r [newsurl]. 'e/data/images/nouserpic.gif' ; if ( empty ( $r [userid])|| $r [checked]==0) { EmptyEcmsCookie(); $mhavelogin =0; } |
也是在else括号里面插入代码