1
BigJim
Change top users block to display random users
  • 2007/9/10 7:30

  • BigJim

  • Just popping in

  • Posts: 78

  • Since: 2007/7/16


I'd like to have a block on my homepage that randomly shows user's avatars.

So is it possible to alter the system's top users block to show 10 randomly selected users (perhaps updating on a daily basis) or am I asking for too much???

Also is it possible to only show users who have added avatars (coz otherwise it could just be showing 10 empty blocks)!!!

Thanks a lot for any suggestions!!

2
BigJim
Re: Change top users block to display random users
  • 2007/10/29 9:32

  • BigJim

  • Just popping in

  • Posts: 78

  • Since: 2007/7/16


Can anybody help me on this?

Still hoping to get this done.

Right now my homepage shows the 10 newest users and also another block showing the top posters

But what I want to do is have a block that can display users randomly. So every time the page is displayed it would show the avatars of different users.

Does anyone know how to do this? Or am I asking for the moon?

Thanks

3
mjoel
Re: Change top users block to display random users
  • 2007/10/30 9:07

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


bump...i'm looking for this too

4
zyspec
Re: Change top users block to display random users
  • 2007/10/30 13:48

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


Let me preface this by "I haven't actually tried this but..."

As long as you don't mind not also having a 'top posters' block the easiest way is to change the top poster block into a random user block.

You'll need to comment out a couple of lines in the 'b_system_topposters_show' function and then add a couple of new lines. In XOOPS versions 2.0.16-2.0.17.1 comment out lines 300-301 in ./modules/system/blocks/system_blocks.php so they look like this:
//    $criteria->setOrder('DESC');
//    $criteria->setSort('posts');

Then add the following 2 lines immediately after those two lines.
$criteria->add('user_avatar','blank.gif','<>')
    
$criteria->setOrder('RAND');


I believe that should do it...

5
mjoel
Re: Change top users block to display random users
  • 2007/10/30 16:06

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


not working ..blank page after updating the system module...

6
mjoel
Re: Change top users block to display random users
  • 2007/10/30 16:18

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


debug message
Cannot pass parameter 1 by reference in C:\Program Files\xampp\htdocs\project2\modules\system\blocks\system_blocks.php on line 302

7
zyspec
Re: Change top users block to display random users
  • 2007/10/30 17:41

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


sorry small typo in the code... the first line needs a semicolon (';') at the end so the inserted code should look like:
$criteria->add('user_avatar','blank.gif','<>')[b][color=CC0000];[/color][/b]
    
$criteria->setOrder('RAND');


Sorry... dumb mistake.

8
mjoel
Re: Change top users block to display random users
  • 2007/10/30 18:53

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


i noticed the typo before, so i tried it with ; and without ;

but i got the same result, blank page > Cannot pass parameter 1 by reference

update > clear template_c > refresh..

still same problem

9
mjoel
Re: Change top users block to display random users
  • 2007/10/30 19:24

  • mjoel

  • Quite a regular

  • Posts: 325

  • Since: 2006/12/9


...an alternative solution is provided here

i should search harder next time..silly me

zyspec, anyway thanks for the help

p/s: it would be great if you can still give the answer for this thread ..w

10
zyspec
Re: Change top users block to display random users
  • 2007/10/31 1:39

  • zyspec

  • Module Developer

  • Posts: 1095

  • Since: 2004/9/21


Two things....

1st - if you use the solution in the other thread then you'll need to amend the SELECT statement to include a "WHERE user_avatar <> 'blank.gif'" if you want to only show users with an avatar and also add displaying the avatar to the block...


2nd - I'll have to check into why this select won't work. At first glance it appears the CriteriaCompo doesn't support setting the order by anything other than 'ASC' or 'DESC'... Maybe I'll check into it when I get time.

Glad you found a solution that works for you...

Login

Who's Online

398 user(s) are online (316 user(s) are browsing Support Forums)


Members: 0


Guests: 398


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