function toc_node_block_view in TOC Node 7
Implements hook_block_view().
File
- ./
toc_node.module, line 276
Code
function toc_node_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'toc_node':
if (arg(0) != 'node' || !is_numeric(arg(1))) {
return;
}
// Get the nid
$nid = arg(1);
$node = node_load($nid);
$toc_enabled = variable_get('toc_node_enabled_' . $node->type, 0);
// Check if TOC is enabled for this content type.
if (empty($toc_enabled)) {
return;
}
// Check if TOC is set to not display.
if (!isset($node->toc_node_style) || $node->toc_node_style == 'none') {
return;
}
$node_rendered = node_view($node);
$node_content = drupal_render($node_rendered);
$content = toc_node_generate($node_content, $node->toc_node_style, $node->toc_node_level, $node->toc_node_back_to_top_links, 'toc_list');
if ($content != $node_content) {
$block['subject'] = t('Contents');
$block['content'] = $content;
}
break;
}
return $block;
}