You are here

function nd_eval_block in Node displays 6

Evaluate block field.

Parameters

string $key The name of the key to create.:

array $field The field array.:

stdClass The node object.:

1 call to nd_eval_block()
_nd_nodeapi in ./nd.module
Helper function to alter node properties

File

./nd.module, line 359
Main node displays file.

Code

function nd_eval_block($key, $field, &$node) {
  if (isset($field['code'])) {
    list($module, $delta) = explode('|', $field['code']);
    $block = module_invoke($module, 'block', 'view', $delta);
    if (!empty($block)) {
      switch ($field['render']) {
        case BLOCK_TEMPLATE:
          global $theme_key;
          $block = (object) $block;
          $block->module = $module;
          $block->delta = $delta;
          $block_title = db_result(db_query("SELECT title FROM {blocks} WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $module, $delta, $theme_key));
          if (!empty($block_title)) {
            $block->subject = $block_title == '<none>' ? '' : check_plain($block_title);
          }
          $content = theme('block', $block);
          break;
        case BLOCK_TITLE_CONTENT:
          $content = '<h2 class="block-title">' . $block['subject'] . '</h2>';
          $content .= $block['content'];
          break;
        case BLOCK_CONTENT:
          $content = $block['content'];
          break;
      }
      $node_key = $key . '_rendered';
      $node->{$node_key} = $content;
    }
  }
}