A module to refresh a view after a specified time interval. Includes advanced options to avoid reloading the whole view, and to avoid causing a full Drupal bootstrap at each refresh.

Suitable for usage on liveblogs, activity streams, comment lists, and any other view where new items are frequently added.

Moved from Views Hacks.

QUICK HOWTO: BASIC AUTOREFRESH

  • Create a new page view
  • Add a new header of type Global: Autorefresh
  • Set the interval time to 5000ms
  • Save the view and open its page
  • In a second browser tab, add a new content that fits the view's criteria
  • See the new content in the view!

QUICK HOWTO: INCREMENTAL REFRESH

Use incremental refresh when you don't want to reload the whole view at each refresh. This is handy if rendering the view items needs further client-side work, like reloading a YouTube video.

  • Create a new page view
  • Add a second page display with:
    • A different path
    • A distinctive name like "Incremental Page"
    • A contextual filter of type Content: Post date (with operator)
  • In your original page, add a new header of type Global: Autorefresh with:
    • Set the interval time to 5000ms
    • Check Use a secondary view display to incrementally insert new items only
    • In Secondary display, select the second page you created above
  • Save the view and open its page
  • In a second browser tab, add a new content that fits the view's criteria
  • See the new content in the view!

QUICK HOWTO: USING A PING SCRIPT

Using a ping script is essential for production environments, to avoid a full Drupal bootstrap at each refresh.

  • Create a new page view
  • Copy the file ping.php.example to your Drupal root folder and rename it as ping.php
  • Edit ping.php such that DRUPAL_ROOT points to your Drupal root, and adjust the query:
    $result = $db->query("SELECT count(nid) FROM node WHERE created > $timestamp");

    to reflect your view's generated SQL query. Make sure to keep the created condition in the query.
  • Add a new header of type Global: Autorefresh with:
    • Set the interval time to 5000ms
    • Check Use a ping url
    • In Path to the ping script, enter ping.php
  • Save the view and open its page
  • In a second browser tab, add a new content that fits the view's criteria
  • See the new content in the view!

CREDITS

Sponsored by Meedan, for usage on Al-Masry Al-Youm Liveblog and Checkdesk, among others.

Project Information

Downloads