A module to refresh a view after a specified time interval or when triggered by an event. 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.

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!

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!

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!

HOWTO: Using Node.js and Rules

Using Node.js integration and Rules to avoid polling the server at regular intervals.

  • Enable Node.js integration (latest 7.x-1.x-dev), apply this patch and start the node.js server
  • Enable Rules
  • Create a new page view with a secondary display as in the incremental HOWTO
  • Instead of specifying a time interval, check Use Node.js to refresh the view instead of interval pings
  • Save the view
  • Add a new rule that is triggered by the event corresponding to your use case, e.g. Node: After saving new content
  • Add the action Autorefresh a View through Node.js to your rule, selecting the view display that corresponds to your primary display
  • Open the view's page
  • In a second browser tab, add a new content that fits the view's criteria
  • See the new content in the view!
Supporting organizations: 
Sponsorship

Project information

Releases