Download & Extend

Allow progressive refresh instead of full refresh

Project:Views Hacks
Version:6.x-1.x-dev
Component:Views Filters Auto-refresh
Category:feature request
Priority:normal
Assigned:infojunkie
Status:closed (fixed)

Issue Summary

To reduce server load, allow the admin to specify a secondary URL that will be used by auto-refresh to fetch *new* or *updated* items instead of the full view's load. The frontend code will be responsible for refreshing the page with the new items.

Comments

#1

There should be enough DOM information available to the auto-refresh frontend code, to allow it to correctly place the updated items in the existing View DOM.

#2

#3

Status:active» fixed

More robust version now in dev. Here's how it works:

The basic idea is to provide an "update" view that will only return items that were added since the last refresh. This secondary view accepts a timestamp that is the time of the last refresh.

* Create original view. It has to support AJAX. Add the following PHP code to the header:

<?php
print theme('views_autorefresh', 5000, views_get_current_view(), array(
 
'view_base_path' => 'liveblog/autorefresh', // the path of the update view
 
'view_display_id' => 'page_2', // the display of the update view
 
'view_name' => 'liveblog', // the name of the update view
 
'sourceSelector' => '.view-content', // selector for items container in update view
 
'targetSelector' => '.view-content', // selector for items container in on-page view
 
'firstClass' => 'first', // class name for first element (optional),
 
'lastClass' => 'last', // class name for last element (optional),
 
'oddClass' => 'odd', // class name for odd elements (optional)
 
'evenClass' => 'even', // class name for even elements (optional)
));
?>

The header should show even if the view is empty.

* Create the update view. Typically, this would be a copy of the original view, with the path given above. The main difference is the addition of one argument, typically Node: Post date (with operator) that is also supplied by this module.

That's it!

Future features include:
* New items are only added to the top of the view. Eventually, there should be an option to add them to the bottom instead.
* Twitter style: display a message that informs the user there are more items, without displaying them until the user clicks it.
* Update page title with number of new items.
* Highlight new items for a given time.
* Package the functionality as a header plugin (or display add-on) for Views 3, and as a new display plugin in Views 2.
* Support multiple auto-refresh views per page.

#4

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here