function blog_block in Drupal 5
Same name and namespace in other branches
- 4 modules/blog.module \blog_block()
- 6 modules/blog/blog.module \blog_block()
Implementation of hook_block().
Displays the most recent 10 blog titles.
File
- modules/
blog/ blog.module, line 274 - Enables keeping an easily and regularly updated web page or a blog.
Code
function blog_block($op = 'list', $delta = 0) {
global $user;
if ($op == 'list') {
$block[0]['info'] = t('Recent blog posts');
return $block;
}
else {
if ($op == 'view') {
if (user_access('access content')) {
$result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 10);
if (db_num_rows($result)) {
$block['content'] = node_title_list($result);
$block['content'] .= '<div class="more-link">' . l(t('more'), 'blog', array(
'title' => t('Read the latest blog entries.'),
)) . '</div>';
$block['subject'] = t('Recent blog posts');
return $block;
}
}
}
}
}