Skip to content
Snippets Groups Projects
Unverified Commit 23fc2b7d authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2793169 by Matroskeen, Manuel Garcia, anmolgoyal74, Pooja Ganjage,...

Issue #2793169 by Matroskeen, Manuel Garcia, anmolgoyal74, Pooja Ganjage, Abhijith S, Lendude, dww, quietone: hook_views_post_render provides inaccurate information

(cherry picked from commit acd7ac96)
parent 03d919b0
No related branches found
No related tags found
15 merge requests!2496Issue #3222757 by lauriii, Wim Leers, nod_, rachel_norfolk, itmaybejj,...,!2366Issue #3285105 by Daniel Arend,!2304Issue #3258987: Class "Drupal\Core\Utility\Error" not found in _drupal_error_handler_real() due to bug in PHP 8.1.0-8.1.5,!2148Issue #3270899: Remove Color module from core,!2136Issue #3227824: Move the linkset functionality from the decoupled menus contributed module to core's system module,!2071Issue #927570: Setting 403 or 404 handler to a page that redirects leads to endless loop,!1975Issue #3269749: losing query params from user to user/login redirect,!1959Issue #3236497: Allow other modules to opt out of security release message from update_page_top,!1387Draft: Resolve #2511878 "Support enclosure field",!1282Issue #3227824: Add the decoupled menus module to core,!1229Issue #3225621: Use media query event listener instead of a listener on the resize event,!799Issue #3214332: Preview content is broken in Claro.,!776Resolve #85494 "Use email verification 9.3.x",!558Resolve #3020422 "Toolbar style update",!231Issue #2671162: summary text wysiwyg patch working fine on 9.2.0-dev
......@@ -820,36 +820,37 @@ function hook_views_pre_render(ViewExecutable $view) {
}
/**
* Post-process any rendered data.
* Post-process any render 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.
* This hook can be used by themes.
* The module or theme may add, modify or remove elements in $output after
* rendering.
*
* 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:
* If a module wishes to act on the rendered HTML of the view rather than the
* structured content array, it may use this hook to add a #post_render
* callback:
* @code
* <!--post-FIELD-NID-->
* // The object must implement \Drupal\Core\Security\TrustedCallbackInterface.
* $output['#post_render'][] = '\Drupal\my_module\View::postRender';
* @endcode
* And then in the post-render, create an array with the text that should
* go there:
* @code
* strtr($output, array('<!--post-FIELD-1-->' => 'output for FIELD of nid 1');
* @endcode
* All of the cached result data will be available in $view->result, as well,
* so all ids used in the query should be discoverable.
*
* See \Drupal\Core\Render\RendererInterface::render() for #post_render
* documentation.
*
* Alternatively, it could also implement hook_preprocess_HOOK() for
* the particular view template, if there is one.
*
* @param \Drupal\views\ViewExecutable $view
* The view object about to be processed.
* @param string $output
* A flat string with the rendered output of the view.
* The view object being processed.
* @param array $output
* A structured content array representing the view output. The given array
* depends on the style plugin and can be either a render array or an array of
* render arrays.
* @param \Drupal\views\Plugin\views\cache\CachePluginBase $cache
* The cache settings.
*
* @see \Drupal\views\ViewExecutable
*/
function hook_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache) {
function hook_views_post_render(ViewExecutable $view, array &$output, CachePluginBase $cache) {
// When using full pager, disable any time-based caching if there are fewer
// than 10 results.
if ($view->pager instanceof Drupal\views\Plugin\views\pager\Full && $cache instanceof Drupal\views\Plugin\views\cache\Time && count($view->result) < 10) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment