You are here

function _site_map_blogs in Site map 5

Same name and namespace in other branches
  1. 8 site_map.module \_site_map_blogs()
  2. 6.2 site_map.module \_site_map_blogs()
  3. 6 site_map.module \_site_map_blogs()
  4. 7 site_map.module \_site_map_blogs()

Render the latest blog authors

1 call to _site_map_blogs()
theme_site_map_display in ./site_map.module

File

./site_map.module, line 319
Original author: Nic Ivy Now maintained by by Fredrik Jonsson fredrik at combonet dot se

Code

function _site_map_blogs() {
  if (module_exists('blog')) {
    $title = t('Blogs');
    $output = '<div class="description">' . t("Community blog and recent blog authors at %sn.", array(
      "%sn" => variable_get('site_name', 'Drupal'),
    )) . '</div>';
    $blogs = array();
    $blogs[] .= l(t('All blogs'), 'blog') . (variable_get('site_map_show_rss_links', 1) ? ' ' . theme('site_map_feed_icon', url('blog/feed')) : '');
    $sql = "SELECT DISTINCT u.uid, u.name, count(u.uid) AS numitems\n      FROM {node} n\n      INNER JOIN {users} u ON u.uid = n.uid\n      WHERE n.type = 'blog' AND n.status = 1\n      GROUP BY u.uid\n      ORDER BY numitems DESC, u.name";
    $result = db_query_range($sql, 0, 10);
    while ($blog = db_fetch_object($result)) {
      $blogs[] = l(t("!s's blog", array(
        "!s" => $blog->name,
      )), "blog/{$blog->uid}") . ' (' . $blog->numitems . ')' . (variable_get('site_map_show_rss_links', 1) ? ' ' . theme('site_map_feed_icon', url("blog/{$blog->uid}/feed")) : '');
    }
    $output .= theme('item_list', $blogs);
    $output = theme('box', $title, $output);
  }
  return $output;
}