function CachePluginBase::postRender
Same name in other branches
- 9 core/modules/views/src/Plugin/views/cache/CachePluginBase.php \Drupal\views\Plugin\views\cache\CachePluginBase::postRender()
- 8.9.x core/modules/views/src/Plugin/views/cache/CachePluginBase.php \Drupal\views\Plugin\views\cache\CachePluginBase::postRender()
- 11.x core/modules/views/src/Plugin/views/cache/CachePluginBase.php \Drupal\views\Plugin\views\cache\CachePluginBase::postRender()
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, [
'<!--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.
File
-
core/
modules/ views/ src/ Plugin/ views/ cache/ CachePluginBase.php, line 188
Class
- CachePluginBase
- The base plugin to handle caching.
Namespace
Drupal\views\Plugin\views\cacheCode
public function postRender(&$output) {
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.