forum_block_view
function forum_block_view
forum_block_view($delta = '')
Implements hook_block_view().
Generates a block containing the currently active forum topics and the most recently added forum topics.
File
- modules/forum/forum.module, line 685
- Provides discussion forums.
Code
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; } $block['subject'] = $title; // Cache based on the altered query. Enables us to cache with node access enabled. $block['content'] = drupal_render_cache_by_query($query, 'forum_block_view'); $block['content']['#access'] = user_access('access content'); return $block; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!forum!forum.module/function/forum_block_view/7.x