function blog_block_view

Implements hook_block_view().

Displays the most recent 10 blog titles.

File

modules/blog/blog.module, line 232

Code

function blog_block_view($delta = '') {
    global $user;
    if (user_access('access content')) {
        $result = db_select('node', 'n')->fields('n', array(
            'nid',
            'title',
            'created',
        ))
            ->condition('type', 'blog')
            ->condition('status', 1)
            ->orderBy('created', 'DESC')
            ->range(0, variable_get('blog_block_count', 10))
            ->addTag('node_access')
            ->execute();
        if ($node_title_list = node_title_list($result)) {
            $block['subject'] = t('Recent blog posts');
            $block['content']['blog_list'] = $node_title_list;
            $block['content']['blog_more'] = array(
                '#theme' => 'more_link',
                '#url' => 'blog',
                '#title' => t('Read the latest blog entries.'),
            );
            return $block;
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.