By potential on
Hey guys,
I'm having a little trouble modifying the "Who's New" block. I would like to show people in this block, only if they have uploaded an avitar. Here is the related code from user.module.
case 2:
if (user_access('access content')) {
$result = db_query_range('SELECT uid, name FROM {users} WHERE status != 0 ORDER BY uid DESC', 0, 5);
while ($account = db_fetch_object($result)) {
$items[] = format_name($account);
}
$output = theme('user_list', $items);
$block['subject'] = t('Who\'s new');
$block['content'] = $output;
}
return $block;
Could someone show me how to add if($user->picture).
If possible, could I also display the avitar next to the name?
Any help would be so much appreciated. THANKS!
Comments
Change in SQL
I think it would be best to change the SQL statement.
Change the following:
to this:
Thanks... Add picture?
Thanks that worked well. Do you if its possible to show the avitar along with the name?
I would suggest changing the
I would suggest changing the following:
by adding the image either before or after the username (only pick one):
You will also have to get the picture in the mysql statement. Change:
to:
Recieved an error
Hi Brad,
Thanks for the help man. Unforunatly, I got an error when I tried that.
Fatal error: Cannot use object of type stdClass as array in F:\www\htdocs\modules\user.module on line 535
I know we are close tho.
Here is some code I found elsewhere and modified. It almost works perfectly.
I don't think I'm using the correct method to link to the profile, and I also think my php syntax is off somewhere. Can you take a look at my code and let me know how to improve it?
THANKS!
Try this...
Your example code helped me. I thought that $user_info was an array, but using the "->" is correct. I'm crossing my fingers this time. This is just modified from the original.
If you'd like to use something like the one you found, I'd suggest doing it the following way:
Selecting only the needed fields in the SQL statement will improve performance. The html also needed some adjustment.
See if you can get one of these to work and let me know how it works out.
Works really good
Thanks Brad,
I used the second set of code and its working wonderfully.
If you have a chance, can you take a look at another php question I have. It hasn't received a response in a few days.
http://drupal.org/node/46461
Thanks for everything so far. My site looks much better already.
Man this first one isn't working for me...help?
I think it's a path issue. It wants to show an image, but it's showing a broken image with a red x. what the ...am I doing wrong?
I posted this exact code in in case 2 on user.module
It's fine except the broken image...does this have to do with my drupal being in a subdirectory? help please. Thank you.
if (user_access('access content')) {
picture.'">'.format_name($account);
$result = db_query_range('SELECT uid, name, picture FROM {users} WHERE status != 0 AND picture != "" ORDER BY uid DESC', 0, 5);
while ($account = db_fetch_object($result)) {
$items[] = '
}
$output = theme('user_list', $items);
$block['subject'] = t('Who\'s new');
$block['content'] = $output;
}
return $block;
Image Path?
I don't know exactly, but what you could do is find out the path of the image it's giving you. In firefox, right click->properties, and it should be the first item. That's where I'd start debugging. If you can't figure out, tell me what the image is pointing to and where it should point to.
--
Bradlis7.com | Churchofchristnet
Thanks for your help...
I got it to work! I appreciate it. Used the same snippet above. If you have any ideas about getting an image to show next the username in the buddylist on the profile page, that's what I'm up to now.
Thanks again.
Its all about sharing.
Interestingly enough I had to combine the MySql query from the upper snippet with the code from the lower one.
I created a custom block and added
Here is the CSS.
#blockpic, #blockpic a{
text-align: center;
text-decoration: none;
}
#new-people{
width: 50px;
width: 50px;
}
I was getting a nasty MySql error whenever I logged out using the lower snippet from http://drupal.org/node/46619#comment-88124 . After several hours of digging I came across a thread dealing with a similar issue http://drupal.org/node/43735 . The gist of that thread was that the db_rewrite_sql() function was causing issues. For the detail hungry folks see http://drupal.org/node/43735#comment-92865 . Thank you both for putting this together I hope someone needing the same feature will benefit from my Franken-snippet. ;)