Full ELMS Learning Network documentation
function hook_views_post_render
Error message
User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).cis7 views.api.php | hook_views_post_render(&$view, &$output, &$cache) |
cle7 views.api.php | hook_views_post_render(&$view, &$output, &$cache) |
elmsmedia7 views.api.php | hook_views_post_render(&$view, &$output, &$cache) |
icor7 views.api.php | hook_views_post_render(&$view, &$output, &$cache) |
meedjum_blog7 views.api.php | hook_views_post_render(&$view, &$output, &$cache) |
mooc7 views.api.php | hook_views_post_render(&$view, &$output, &$cache) |
Post process any rendered data.
This can be valuable to be able to cache a view and still have some level of dynamic output. In an ideal world, the actual output will include HTML comment based tokens, and then the post process can replace those tokens.
Example usage. If it is known that the view is a node view and that the primary field will be a nid, you can do something like this:
<!--post-FIELD-NID-->
And then in the post render, create an array with the text that should go there:
strtr($output, array('<!--post-FIELD-1-->' => 'output for FIELD of nid 1');
All of the cached result data will be available in $view->result, as well, so all ids used in the query should be discoverable.
This hook can be utilized by themes.
Parameters
$view: The view object about to be processed.
$output: A flat string with the rendered output of the view.
$cache: The cache settings.
Related topics
- view::render in sites/
all/ modules/ ulmus/ views/ includes/ view.inc - Render this view for a certain display.
File
- sites/
all/ modules/ ulmus/ views/ views.api.php, line 973 - Describe hooks provided by the Views module.
Code
function hook_views_post_render(&$view, &$output, &$cache) {
// When using full pager, disable any time-based caching if there are less
// then 10 results.
if ($view->query->pager instanceof views_plugin_pager_full && $cache->options['type'] == 'time' && count($view->result) < 10) {
$cache['options']['results_lifespan'] = 0;
$cache['options']['output_lifespan'] = 0;
}
}