function nodeblock_block in Nodeblock 5
Same name and namespace in other branches
- 6 nodeblock.module \nodeblock_block()
Implementation of hook_block().
File
- ./
nodeblock.module, line 109
Code
function nodeblock_block($op = 'list', $delta = 0, $edit = array()) {
$types = node_get_types();
if ($op == 'list') {
foreach ($types as $type) {
if (nodeblock_type_enabled($type)) {
$result = db_query('SELECT * FROM {node} WHERE type="%s" AND status=1', $type->type);
while ($node = db_fetch_object($result)) {
$blocks[$node->nid] = array(
'info' => $node->title . ' (nodeblock)',
);
}
}
}
return $blocks;
}
elseif ($op == 'view') {
$node = node_load($delta);
$block['subject'] = check_plain($node->title);
// using page arg = TRUE since we want the full content (generally speaking)
$block['content'] = node_view($node, FALSE, FALSE, TRUE);
return $block;
}
}