Drupal视图:如何在上次将视图缓存刷新到视图显示时打印

时间:2010-02-26 16:32:13

标签: drupal views

我希望在我的页面上显示“此页面上次刷新:{DATETIME}”

我试图获取缓存日期,但我遇到了View display_handler对象的问题。 $视图 - > display_handler-> get_plugin( '高速缓存');即使View缓存当前设置为1分钟,也为NULL。有任何想法如何打印缓存的DATETIME?

$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 个答案:

答案 0 :(得分:1)

    <?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);

?>