Display random items?

cwhitworth - July 2, 2008 - 16:40
Project:ScrollText
Version:5.x-1.2
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Is there a way to have this module randomly choose the items that it displays? I have a content type set up for members of our trade association. I'm experimenting with using this module to scroll the names of our members across a space on the front page. However, it always chooses the same node as its starting point. It seems to pick the highest numbered node in my content type and work down from there (example: node/1345 then node/1344 then node/1340 and so on). If I were to use ScrollText in this current form, I'd end up with the same business always starting the list and needless to say the other businesses would not be happy. Randomly picking a new starting point each time I think would solve this problem.

Any help or advice would be appreciated. Thanks.

#1

yountod - October 10, 2009 - 18:58

Well it's been a year since you asked, but...

I'm fairly sure you could have MySQL generate a field with a random number in the SQL statement, then ORDER BY that field?

#2

yountod - October 10, 2009 - 19:33

Aww cool... For MySQL, all you have to do is change

ORDER BY n.created

to

ORDER BY RAND()

 
 

Drupal is a registered trademark of Dries Buytaert.