11
trabis
Re: display user avatar in template
  • 2008/7/26 9:21

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


I addded the A, just in case someone need this to. See ya.

12
Danielw42
Re: display user avatar in template
  • 2010/8/3 1:21

  • Danielw42

  • Just popping in

  • Posts: 15

  • Since: 2010/1/14


Hi
I have a question. How to modify this block to display my avatar when I am on my own profile. And when I will visit someone's else profile, I will see his/her avatar.

13
trabis
Re: display user avatar in template
  • 2010/8/3 18:59

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

Danielw42 wrote:
Hi
I have a question. How to modify this block to display my avatar when I am on my own profile. And when I will visit someone's else profile, I will see his/her avatar.


Try this:
<{php}>  
global 
$xoopsUser
$uid = isset($_GET['uid']) ? intval($_GET['uid']) : -1;
$mHandler xoops_getHandler('member');
$user $mHandler->getUser($uid);
if (!
is_object($user) && is_object($xoopsUser)) {
    
$user =& $xoopsUser;
}
if (
is_object($user)) { 
$uavatar $user->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}>

14
Danielw42
Re: display user avatar in template
  • 2010/8/3 21:43

  • Danielw42

  • Just popping in

  • Posts: 15

  • Since: 2010/1/14


What I can say trabis, you are a genius. Thank you man!

15
Danielw42
Re: display user avatar in template
  • 2010/8/5 7:16

  • Danielw42

  • Just popping in

  • Posts: 15

  • Since: 2010/1/14


Trabis, one more thing. How to add display name, user location...to this block? What about displaying extra fields created in user profile module?

16
noo-b
Re: display user avatar in template
  • 2010/8/5 9:01

  • noo-b

  • Just can't stay away

  • Posts: 456

  • Since: 2007/10/23


I Love Xoops

17
Danielw42
Re: display user avatar in template
  • 2010/8/5 21:38

  • Danielw42

  • Just popping in

  • Posts: 15

  • Since: 2010/1/14


Thanks for your reply noo-b.
I know how to do this. I am asking how to display display name, user from.... in a block ( not in a template).
If I insert $xoopsUser->getVar('uname'); , my name is both displayed on my profile and someone else's profile.


18
ghia
Re: display user avatar in template
  • 2010/8/5 21:43

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Disable caching for the block.

19
trabis
Re: display user avatar in template
  • 2010/8/5 22:48

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

Danielw42 wrote:
Trabis, one more thing. How to add display name, user location...to this block? What about displaying extra fields created in user profile module?


Just need to add an extra line:
<{php}>   
global 
$xoopsUser;  
$uid = isset($_GET['uid']) ? intval($_GET['uid']) : -1
$mHandler xoops_getHandler('member'); 
$user $mHandler->getUser($uid); 
if (!
is_object($user) && is_object($xoopsUser)) { 
    
$user =& $xoopsUser

if (
is_object($user)) {  
$GLOBALS['xoopsTpl']->assign('user'$user->getValues());
$uavatar $user->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}>


Then you can get any user data from the $user array
<{$user.uname}>
<{
$user.email}>


Hum, from profile it needs to be done in other way, there should be a thread about it somewhere.

20
Danielw42
Re: display user avatar in template
  • 2010/8/6 3:18

  • Danielw42

  • Just popping in

  • Posts: 15

  • Since: 2010/1/14


You are always correct. Thanks again trabis.

Login

Who's Online

377 user(s) are online (274 user(s) are browsing Support Forums)


Members: 0


Guests: 377


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