function _tableofcontents_block_view in Table of Contents 7
Same name and namespace in other branches
- 6.3 tableofcontents_block/tableofcontents_block.module \_tableofcontents_block_view()
Create the block if user has permission and we are viewing a node and the node has enough data to generate a table of contents.
1 call to _tableofcontents_block_view()
- tableofcontents_block_block_view in tableofcontents_block/
tableofcontents_block.module - Implements hook_block_view().
File
- tableofcontents_block/
tableofcontents_block.module, line 14 - main file for module providing a block
Code
function _tableofcontents_block_view() {
global $_tableofcontents_block_processing;
global $_tableofcontents_block_toc;
// check whether we are viewing a node
if (arg(0) != 'node' || !is_numeric(arg(1))) {
// no block
// no block
return;
}
$node = node_load(arg(1));
// verify user's access to view the node
if (!node_access('view', $node)) {
return;
}
$_tableofcontents_block_processing = TRUE;
$text = node_view($node, 'full', $node->language);
unset($_tableofcontents_block_processing);
module_load_include('pages.inc', 'tableofcontents');
$_tableofcontents_block_toc = '[toc]';
$text = _tableofcontents_process(drupal_render($text['body']), 'block');
unset($_tableofcontents_block_toc);
if ($text) {
return $text;
}
// no block
}