forum_block_view
- Versions
- 7
forum_block_view($delta = '')
Implement hook_block_view().
Generates a block containing the currently active forum topics and the most recently added forum topics.
Code
modules/forum/forum.module, line 548
<?php
function forum_block_view($delta = '') {
$query = db_select('forum_index', 'f')
->fields('f')
->addTag('node_access');
switch ($delta) {
case 'active':
$title = t('Active forum topics');
$query
->orderBy('f.last_comment_timestamp', 'DESC')
->range(0, variable_get('forum_block_num_active', '5'));
break;
case 'new':
$title = t('New forum topics');
$query
->orderBy('f.created', 'DESC')
->range(0, variable_get('forum_block_num_new', '5'));
break;
}
$cache_keys = array_merge(array('forum', $delta), drupal_render_cid_parts());
// Cache based on the altered query. Enables us to cache with node access enabled.
$query->preExecute();
$cache_keys[] = md5(serialize(array((string) $query, $query->getArguments())));
$block['subject'] = $title;
$block['content'] = array(
'#access' => user_access('access content'),
'#pre_render' => array('forum_block_view_pre_render'),
'#cache' => array(
'keys' => $cache_keys,
'expire' => CACHE_TEMPORARY,
),
'#query' => $query,
);
return $block;
}
?>Login or register to post comments 