1
blackrx
display user avatar in template
  • 2008/7/26 6:45

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


edit: actually i want this in the user menu template not in a custom block

i want when people login they see
their avatar and username

anyone know how ?

2
blackrx
Re: display user avatar in custom block
  • 2008/7/26 7:10

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


this is for PM ...what about user avatar ??
<{php}>
GLOBAL 
$xoopsUser;
$pm_handler =& xoops_gethandler('privmessage');
$uid $xoopsUser->getVar('uid');
$criteria = new CriteriaCompo(new Criteria('read_msg'0));
$criteria->add(new Criteria('to_userid'$uid));
$msgcount $pm_handler->getCount($criteria);
$GLOBALS['xoopsTpl']->assign('msgcount'$msgcount);
<{/
php}>

i found this but not working for me

https://xoops.org/modules/newbb/viewtopic.php?topic_id=38494&forum=20&post_id=169280

3
trabis
Re: display user avatar in custom block
  • 2008/7/26 7:25

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


<{php}> 
GLOBAL 
$xoopsUser;
if (
is_object($xoopsUser)) {
$uavatar $xoopsUser->getVar('user_avatar');
if (
file_exists(XOOPS_ROOT_PATH.'/uploads/'.$uavatar)) {
$GLOBALS['xoopsTpl']->assign('uavatar''.XOOPS_URL.'/uploads/'.$uavatar.'" alt="avatar" />');
}else{
$GLOBALS['xoopsTpl']->assign('uavatar''');
}
}
<{/
php}>


Then use <{$uavatar}> to display it

No tested

4
blackrx
Re: display user avatar in custom block
  • 2008/7/26 7:39

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


thank you trabis..not working...i try this

<{if $uavatar != ""}>
      <
img src="<{$uavatar}>" alt="" width="32" /><br />
      <{/if}>

5
trabis
Re: display user avatar in custom block
  • 2008/7/26 7:45

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


no, no, if you want to use tag in html then use this instead:
<{php}> 
GLOBAL 
$xoopsUser;
if (
is_object($xoopsUser)) {
$uavatar $xoopsUser->getVar('user_avatar');
if (
file_exists(XOOPS_ROOT_PATH.'/uploads/'.$uavatar)) {
$GLOBALS['xoopsTpl']->assign('uavatar'XOOPS_URL.'/uploads/'.$uavatar);
}else{
$GLOBALS['xoopsTpl']->assign('uavatar''');
}
}
<{/
php}>


The original ideia was to use just <{$uvatar}> and nothing else.

6
blackrx
Re: display user avatar in custom block
  • 2008/7/26 7:49

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


yipee now it is working

thank you very much trabis..

i should recommend you to be xoopser of the month

7
trabis
Re: display user avatar in custom block
  • 2008/7/26 7:58

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


AHAH, no, no, I have been very lazy this month. By the way, you did most of the job in your research by posting those two snipets. Maybe I would not have helped if you have just asked.

Thanks

8
blackrx
Re: display user avatar in template
  • 2008/7/26 8:11

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


heheh..anyway thank you

for the username part i use this <{$xoops_uname}> its working

one last question..how do i make when people havent upload their avatar i will display a picture (no avatar yet)

if their have avatar it will show their avatar

i tried this but not working

<{if $uavatar == "blank.gif"}> 
<
center> <img src="<{$xoops_url}>/uploads/noavatar.jpg" alt="<{$xoops_uname}>" title="<{$xoops_uname}>">center><br />
     
 <{else}>
<
center>   <img src="<{$uavatar}>" alt="<{$xoops_uname}>" title="<{$xoops_uname}>">center><br />
     

 <{/if}>

9
trabis
Re: display user avatar in template
  • 2008/7/26 8:20

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Do it in the php section and keep the same html:
From the second example:
<{php}> 
GLOBAL 
$xoopsUser;
if (
is_object($xoopsUser)) {
$uavatar $xoopsUser->getVar('user_avatar');
if (
file_exists(XOOPS_ROOT_PATH.'/uploads/'.$uavatar) && $uavatar != 'blank.gif') {
$GLOBALS['xoopsTpl']->assign('uavatar'XOOPS_URL.'/uploads/'.$uavatar);
}else{
$GLOBALS['xoopsTpl']->assign('uavatar'XOOPS_URL.'/uploads/noavatar.jpg');
}
}
<{/
php}>


In my site I have replaced blank.gif by my own blank.gif(that is not blank att all, eheh) to keep it simple.

10
blackrx
Re: display user avatar in template
  • 2008/7/26 8:40

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


&& $uvatar != 'blank.gif'

you missed an A...Thanks again trabis..working perfectly as what i want !!

Thank you

Login

Who's Online

337 user(s) are online (216 user(s) are browsing Support Forums)


Members: 0


Guests: 337


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits