This project is not covered by Drupal’s security advisory policy.

New Views Options!

D7 alt: https://www.drupal.org/project/views_random

Adds a new sort type to views. It's under sort criteria -> Global: Javascript Random.

Why
Lets say this view is used to rotate an ad on your site. If that is cached then the same ad shows until the page cache is cleared.

How
Lets say for the view it will display 3 nodes; with this plugin it will load 25 nodes (number configurable) and then client side it will use Javascript's Math.random() to select what 3 nodes to display. Inside a noscript tag it will use css to unhide the first 3 nodes, but these will not change until the page is created again. This also adds a SQL random to your results so the noscript version is acceptable.

Supported styles
The following styles (Views: Basic settings) have been tested and appear to work correctly.

  • Unformatted
  • Table
  • HTML List

Other styles may work; if they do not & you need it, please create an issue; support for it might be added in.

Unsupported styles
These are views styles that can not easily be done at the moment.

  • Grid (patches welcome!)
  • Jump Menu
  • Panels
  • Bulk Operations
  • GMap
  • XML data document

Project Information

Downloads