tags:

views:

88

answers:

1

I want to have on my page something like "This page last refreshed on: {DATETIME}"

I have tried to get the cache date but I have having trouble with the View display_handler object. $view->display_handler->get_plugin('cache'); is NULL, even though the View cache is currently set to 1 min. Any ideas how to print the DATETIME of the cache?

$view = views_get_view('Petition') or die ('no such view');
$view->set_display('Petition Signers Page');
$plugin = $view->display_handler->get_plugin('cache');
var_dump($view->display_handler);  //this is defined
var_dump($plugin); //this is NULL
$cache = cache_get($plugin->get_results_key(),$plugin->table));
$timestamp = $cache->created;
+1  A: 
    <?php

$view = views_get_view('Consignment') or die ('no such view');
$view->set_display('page_1');
$view->execute('page_1');
$plugin = $view->display_handler->get_cache_plugin();
$cache = cache_get($plugin->get_output_key(), $plugin->table);
$timestamp = $cache->created;

print format_date($timestamp);

?>
Nikit
Change Consignment and page_1 properly to your views names. execute() is need for getting result data for calculating md5 hash.
Nikit