4.6.x blog.module blog_page_last()
4.7.x blog.module blog_page_last()
5.x blog.module blog_page_last()
6.x blog.pages.inc blog_page_last()
7.x 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
Implementation of hook_menu().

File

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

Code

function blog_page_last() {
  global $user;

  $output = '';
  $items = array();

  if (user_access('create blog entries')) {
    $items[] = l(t('Create new blog entry.'), "node/add/blog");
  }

  $output = theme('item_list', $items);

  $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10));
  $has_posts = FALSE;

  while ($node = db_fetch_object($result)) {
    $output .= node_view(node_load($node->nid), 1);
    $has_posts = TRUE;
  }

  if ($has_posts) {
    $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
  }
  else {
    drupal_set_message(t('No blog entries have been created.'));
  }
  drupal_add_feed(url('blog/feed'), t('RSS - blogs'));

  return $output;
}

Comments

amaisano’s picture

Can this function be modified outside of the module, so that in addition to only printing Published nodes, it will also exclude nodes that have other attributes, like a custom status like n.archived? I used Custom Publish Options to create an "Archived" status, which is intended for blog posts that can still be accessed individually, but should not show up on blog post lists...