在用帝國(guó)cms7.5做網(wǎng)站的時(shí)候會(huì)在網(wǎng)站首頁(yè)添加會(huì)員登錄框,當(dāng)用戶(hù)登錄完成后,會(huì)顯示登錄用戶(hù)的信息,但是帝國(guó)CMS提供的loginjs.php文件中并沒(méi)有調(diào)用會(huì)員頭像的方法,下面主要為大家介紹在登錄狀態(tài)模板中調(diào)用會(huì)員頭像的方法:
首先打開(kāi)文件:/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_改成自己的。
然后在需要調(diào)用頭像的地方使用下面的代碼調(diào)用頭像:
<img src=
""
>
如果會(huì)員未上傳頭像,則用一張默認(rèn)圖片代替:
<img src=
""
>
以上方法經(jīng)過(guò)驗(yàn)證,貌似不好用
以下方法,經(jīng)楊青青小姐姐測(cè)試過(guò),好用:
打開(kāi)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';
在登錄狀態(tài)模板中使用<?=$userpic?>調(diào)用會(huì)員頭像
——————–備注—-
文件: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;
}
以上文件,一刷新緩存,改了的文件也會(huì)白改,所以,還需要在另外一個(gè)地方修改文件:
打開(kāi)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括號(hào)里面插入代碼