1
amrufz
how to alter the search result in user profile 1.58?
  • 2010/8/29 2:32

  • amrufz

  • Just popping in

  • Posts: 5

  • Since: 2009/8/1 1


Hi.. I really need some help. I am using Xoops 2.4.5.

How to alter the search result in USER PROFILE 1.58 so that when I search member, the result will display NAME and resized AVATAR instead of Username and Email.

Really appreciate if someone can help me to solve this problem. Thanks.

2
amrufz
Re: how to alter the search result in user profile 1.58?
  • 2010/8/29 2:41

  • amrufz

  • Just popping in

  • Posts: 5

  • Since: 2009/8/1 1


I want the NAME and resized AVATAR to be fixed.

I try to edit search.php file and change 'uname' to 'name' but then instead of display NAME it turn out to be blank. BTW I already created 1 field named 'name' in user profile 1.58's database. Thanks. Hope someone can help me.

3
ghia
Re: how to alter the search result in user profile 1.58?
  • 2010/8/29 7:12

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


The username is obtained by this function.
$uname XoopsUser::getUnameFromId($results[$i]['uid']);
You can't simply change the variable to name and expect that this will be printed. You must use other functions such as creating a temporary user object, to obtain the avatar and profile variable.
Beware: many users don't want their real name published on websites.

4
amrufz
Re: how to alter the search result in user profile 1.58?
  • 2010/8/29 9:23

  • amrufz

  • Just popping in

  • Posts: 5

  • Since: 2009/8/1 1


Thanks Ghia for the reply.. I currently in the process of developing website for my batch. It is a closed-community website. Here is the code in search.php:-

//Sort information         
foreach (array_keys($users) as $k) {             
    
$userarray = array();             
    
$userarray["output"][] = "$users[$k]->getVar('uid') . "'>" $users[$k]->getVar('uname') . "";             
    
$userarray["output"][] = ( $users[$k]->getVar('user_viewemail') == || $GLOBALS['xoopsUser']->isAdmin() ) ? $users[$k]->getVar('email') : "";              

    foreach (
array_keys($fields) as $i) {                 
        if (
in_array($fields[$i]->getVar('field_id'), $searchable_fields) && in_array($fields[$i]->getVar('field_type'), $searchable_types) && in_array($fields[$i]->getVar('field_name'), $searchvars)) {                     
            
$userarray["output"][] = $fields[$i]->getOutputValue($users[$k], $profiles[$k]);                 
        }    
    }             
    
$GLOBALS['xoopsTpl']->append('users'$userarray);             
    unset(
$userarray);


First I make a new field named 'name' in the database. Then I changed the above code to:-

//Sort information         
foreach (array_keys($users) as $k) {             
    
$userarray = array();             
    
$userarray["output"][] = "$users[$k]->getVar('uid') . "'>" $users[$k]->getVar('name') . "";             
    
$userarray["output"][] = ( $users[$k]->getVar('user_viewemail') == || $GLOBALS['xoopsUser']->isAdmin() ) ? $users[$k]->getVar('email') : "";


What do you mean by creating a temporary user object? Can you please explain.. Sorry I'm a newbie.. thanks a lot.

Login

Who's Online

232 user(s) are online (31 user(s) are browsing Support Forums)


Members: 0


Guests: 232


more...

Donat-O-Meter

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

Latest GitHub Commits