? 173037.patch ? 173037_4.patch Index: includes/pager.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/pager.inc,v retrieving revision 1.62 diff -u -p -r1.62 pager.inc --- includes/pager.inc 2 Aug 2007 10:58:41 -0000 1.62 +++ includes/pager.inc 26 Oct 2007 00:21:22 -0000 @@ -49,9 +49,6 @@ * @ingroup database */ function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) { - global $pager_page_array, $pager_total, $pager_total_items; - $page = isset($_GET['page']) ? $_GET['page'] : ''; - // Substitute in query arguments. $args = func_get_args(); $args = array_slice($args, 4); @@ -64,15 +61,29 @@ function pager_query($query, $limit = 10 if (!isset($count_query)) { $count_query = preg_replace(array('/SELECT.*?FROM /As', '/ORDER BY .*/'), array('SELECT COUNT(*) FROM ', ''), $query); } + // Initialize the pager array and position + $pos = pager_init($limit, $element, db_result(db_query($count_query, $args))); + // Return the results based on the position and limit + return db_query_range($query, $args, $pos, $limit); +} + +/** + * Initialize the global pager variables without using pager_query, + */ +function pager_init($limit = 10, $element = 0, $count) { + global $pager_page_array, $pager_total, $pager_total_items; + $page = isset($_GET['page']) ? $_GET['page'] : ''; // Convert comma-separated $page to an array, used by other functions. $pager_page_array = explode(',', $page); - // We calculate the total of pages as ceil(items / limit). - $pager_total_items[$element] = db_result(db_query($count_query, $args)); + // calculate the total of pages as ceil(items / limit). + $pager_total_items[$element] = $count; $pager_total[$element] = ceil($pager_total_items[$element] / $limit); $pager_page_array[$element] = max(0, min((int)$pager_page_array[$element], ((int)$pager_total[$element]) - 1)); - return db_query_range($query, $args, $pager_page_array[$element] * $limit, $limit); + + // return the current position + return $pager_page_array[$element] * $limit; } /**