diff --git a/modules/block/block.api.php b/modules/block/block.api.php index 90e23bd..3301add 100644 --- a/modules/block/block.api.php +++ b/modules/block/block.api.php @@ -205,30 +205,32 @@ function hook_block_save($delta = '', $edit = array()) { * @see hook_block_view_MODULE_DELTA_alter() */ function hook_block_view($delta = '') { - // This example comes from node.module. Note that you can also return a - // renderable array rather than rendered HTML for 'content'. - $block = array(); + // This example comes from blog.module which only provides a single block + // so it ignores the $delta parameter. + global $user; - switch ($delta) { - case 'syndicate': - $block['subject'] = t('Syndicate'); - $block['content'] = theme('feed_icon', array('url' => url('rss.xml'), 'title' => t('Syndicate'))); - break; + 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(); - case 'recent': - if (user_access('access content')) { - $block['subject'] = t('Recent content'); - if ($nodes = node_get_recent(variable_get('node_recent_block_count', 10))) { - $block['content'] = theme('node_recent_block', array( - 'nodes' => $nodes, - )); - } else { - $block['content'] = t('No content available.'); - } - } - break; + 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; + } } - return $block; } /**