You are here

21 February 2014

Add content to view header, footer, before or after using hook_views_pre_render() in Drupal 7. Using hook_views_pre_render gives you the opportunity to use values from executed views query.

Source code viewer
  1. /**
  2.  * Implements hook_views_pre_render().
  3.  */
  4. function HOOK_views_pre_render(&$view) {
  5. if ($view->name === 'my_view') {
  6. $content = 'This content will appear before header section of your view.';
  7. $view->attachment_before = $content;
  8. $view->attachment_after = $content;
  9. }
  10. }
  11.  
Programming Language: PHP