You are here

function blog_page_last in Drupal 7

Same name and namespace in other branches
  1. 4 modules/blog.module \blog_page_last()
  2. 5 modules/blog/blog.module \blog_page_last()
  3. 6 modules/blog/blog.pages.inc \blog_page_last()

Menu callback; displays a Drupal page containing recent blog entries of all users.

1 string reference to 'blog_page_last'
blog_menu in modules/blog/blog.module
Implements hook_menu().

File

modules/blog/blog.pages.inc, line 55
Page callback file for the blog module.

Code

function blog_page_last() {
  global $user;
  $build = array();
  $query = db_select('node', 'n')
    ->extend('PagerDefault');
  $nids = $query
    ->fields('n', array(
    'nid',
    'sticky',
    'created',
  ))
    ->condition('type', 'blog')
    ->condition('status', 1)
    ->orderBy('sticky', 'DESC')
    ->orderBy('created', 'DESC')
    ->limit(variable_get('default_nodes_main', 10))
    ->addTag('node_access')
    ->execute()
    ->fetchCol();
  if (!empty($nids)) {
    $nodes = node_load_multiple($nids);
    $build += node_view_multiple($nodes);
    $build['pager'] = array(
      '#theme' => 'pager',
      '#weight' => 5,
    );
  }
  else {
    drupal_set_message(t('No blog entries have been created.'));
  }
  drupal_add_feed('blog/feed', t('RSS - blogs'));
  return $build;
}