You are here

function nodeblock_node_load in Nodeblock 7

Implements hook_node_load().

File

./nodeblock.module, line 477
Enables use of specified node types as custom blocks.

Code

function nodeblock_node_load($nodes) {
  if (_nodeblock_table_exists()) {
    $query = db_select('nodeblock', 'nb')
      ->fields('nb')
      ->condition('nid', array_keys($nodes));
    $nodeblocks = $query
      ->execute()
      ->fetchAllAssoc('nid');
    foreach ($nodes as $nid => $node) {
      if (nodeblock_type_enabled($node->type) && isset($nodeblocks[$node->nid])) {
        $node->nodeblock = (array) $nodeblocks[$node->nid];

        // These values are not stored in the db.
        $node->nodeblock['custom_machine_name'] = $node->nodeblock['machine_name'] != $node->nid;
        foreach (_nodeblock_node_languages($node) as $langcode) {
          $real_block_title = _nodeblock_block_title($node, $langcode);
          $nodes[$nid]->nodeblock['real_block_title'][$langcode] = $real_block_title;
          $nodes[$nid]->nodeblock['custom_block_title'][$langcode] = $real_block_title != _nodeblock_node_title($node, $langcode);
        }
      }
    }
  }
}