1.20.x views.api.php hook_views_post_build(&$view)

This hook is called right after the build process. The query is now fully built, but it has not yet been run through db_rewrite_sql.

Adding output to the view can be accomplished by placing text on $view->attachment_before and $view->attachment_after.

Parameters

$view: The view object about to be processed.

Related topics

File

modules/views/views.api.php, line 746
Describe hooks provided by the Views module.

Code

function hook_views_post_build(&$view) {
  // If the exposed field 'type' is set, hide the column containing the content
  // type. Note that this is a solution for a particular view, and makes
  // assumptions about both exposed filter settings and the fields in the view.
  // Also note that this alter could be done at any point before the view being
  // rendered.
  if ($view->name == 'my_view' && isset($view->exposed_raw_input['type']) && $view->exposed_raw_input['type'] != 'All') {
    // 'Type' should be interpreted as content type.
    if (isset($view->field['type'])) {
      $view->field['type']->options['exclude'] = TRUE;
    }
  }
}