You are here

function boost_views_pre_render in Boost 6

Implementation of hook_views_pre_render().

This is called right before the render process. Used to grab the NID's listed in this view, and set the view node relationship in the database.

Parameters

&$view: reference to the view being worked on

File

./boost.module, line 275
Provides static file caching for Drupal text output. Pages, Feeds, ect...

Code

function boost_views_pre_render(&$view) {

  // return if not a view, page not going to be cached, or if database turned off
  if (is_null($view) || !$GLOBALS['_boost_cache_this'] || BOOST_NO_DATABASE) {
    return;
  }

  // return if view doesn't belong in the set of views to search
  $views = boost_views_get_valid_array();
  $hash = $view->name . ' - ' . $view->current_display;
  if (!array_key_exists($hash, $views)) {
    return;
  }
  foreach ($view->result as $item) {

    // skip if nid is not a number
    if (!is_numeric($item->nid)) {
      continue;
    }
    $node = boost_node_get_basics($item->nid);

    // skip if node type is not set
    if (!isset($node->type)) {
      continue;
    }

    // set data
    $relationship = array(
      'child_page_callback' => 'node',
      'child_page_type' => $node->type,
      'child_page_id' => $item->nid,
    );
    if (BOOST_VERBOSE >= 9) {
      $relationship['debug'] = array(
        'view-name' => $view->name,
        'view-display' => $view->current_display,
        'node-path' => $node->path,
      );
    }

    // send to global
    $GLOBALS['_boost_relationships'][] = $relationship;
  }
}