statistics_top_pages

Versions
4.6 – 7
statistics_top_pages()

Menu callback; presents the "Top pages" page.

Code

modules/statistics.module, line 253

<?php
function statistics_top_pages() {
  $sql = "SELECT COUNT(path) AS hits, path, title FROM {accesslog} GROUP BY path, title";
  $sql_cnt = "SELECT COUNT(DISTINCT(path)) FROM {accesslog}";

  $header = array(
    array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
    array('data' => t('Page'), 'field' => 'path')
  );
  $sql .= tablesort_sql($header);
  $result = pager_query($sql, 30, 0, $sql_cnt);

  while ($page = db_fetch_object($result)) {
    $rows[] = array($page->hits, _statistics_format_item($page->title, $page->path));
  }
  if ($pager = theme('pager', NULL, 30, 0, tablesort_pager())) {
    $rows[] = array(array('data' => $pager, 'colspan' => '2'));
  }

  drupal_set_title(t('Top pages in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200)))));
  print theme('page', theme('table', $header, $rows));
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.