Return to Snippet

Revision: 30724
at August 25, 2010 02:04 by hiddentao


Updated Code
/**
 * Return themed pager using same markup and CSS classes as the standard Drupal pager.
 *
 * @param  $total_pages total no. of pages.
 * @param  $current_page the current page being viewed (1 <= $current_page <= $total_pages).
 * @param  $num_pages_to_show no. of pages links for, excluding first, next, previous and last links .
 * @param  $base_url the base URL for paging links. Each paging link will be at $base_url?page=<page_num>
 * @return themed paging links; empty string if there is only one page in total.
 */
function garland_simple_pager_links($total_pages, $current_page, $num_pages_to_show, $base_url) {

  static $buttons;
  if (empty($buttons)) {
    $buttons = array(
      'first' => array('text' => t('&laquo; first'), 'link_tooltip' => t('Go to first page')),
      'prev' => array('text' => t('&lsaquo; previous'), 'link_tooltip' => t('Go to previous page')),
      'next' => array('text' => t('next &rsaquo;'), 'link_tooltip' => t('Go to next page')),
      'last' => array('text' => t('last &raquo;'), 'link_tooltip' => t('Go to last page')),
      'current' => array('class' => 'current'),
      'ellipsis' => array('text' => '...'),
    );
  }

  // show nothing if only one page
  if (1 >= $total_pages)
    return '';

  // remove all query params from the base URL
  $base_url = ltrim($base_url,'/');

  // the first page in current set of pages
  $pager_first = $current_page - intval($num_pages_to_show / 2);
  // the last page in current set of pages
  $pager_last = $current_page + intval($num_pages_to_show / 2);

  // normalize
  if (1 > $pager_first) {
    $pager_last += (1 - $pager_first);
    $pager_first = 1;
  }
  if ($total_pages < $pager_last) {
    $pager_first -= ($pager_last - $total_pages);
    if (1 > $pager_first)
      $pager_first = 1;
    $pager_last = $total_pages;
  }

  $items = array();

  // show 'prev' button
  if (1 < $current_page) {
    // show 'first' button
    if (1 < $pager_first) {
      $items[] = array(
        'class' => 'pager-first',
        'data' => theme('simple-pager-link', $base_url, 1, $buttons['first']),
      );
    }
    $items[] = array(
      'class' => 'pager-previous',
      'data' => theme('simple-pager-link', $base_url, $current_page-1, $buttons['prev']),
    );
    // show ellipsis
    if (1 < $pager_first) {
      $items[] = array(
        'class' => 'pager-ellipsis',
        'data' => theme('simple-pager-link', $base_url, '...', $buttons['ellipsis']),
      );
    }
  }

  // page links
  for ($i=$pager_first; $i<=$pager_last; ++$i) {
    if ($i == $current_page) {
      $items[] = array(
        'class' => 'pager-current',
        'data' => theme('simple-pager-link', $base_url, $i, $buttons['current']),
      );
    } else {
      $items[] = array(
        'class' => 'pager-item',
        'data' => theme('simple-pager-link', $base_url, $i, array('text' => $i, 'link_tooltip' => t('Goto page @d',array('@d' => $i)))),
      );
    }
  }

  // show 'next' button
  if ($total_pages > $current_page) {
    // show ellipsis
    if ($total_pages > $pager_last) {
      $items[] = array(
        'class' => 'pager-ellipsis',
        'data' => theme('simple-pager-link', $base_url, '...', $buttons['ellipsis']),
      );
    }
    $items[] = array(
      'class' => 'pager-next',
      'data' => theme('simple-pager-link', $base_url, $current_page+1, $buttons['next']),
    );
    // show 'last' button
    if ($total_pages > $pager_last) {
      $items[] = array(
        'class' => 'pager-last',
        'data' => theme('simple-pager-link', $base_url, $total_pages, $buttons['last']),
      );
    }
  }

  return theme('item_list', $items, NULL, 'ul', array('class' => 'pager'));
}


/**
 * Return a themed pager link.
 *
 * @param  $base_url the base URL to add the paging query param to.
 * @param  $page the number of the page to link to.
 * @param  $button_attributes array('link_tooltip' =>, 'text' => 'class' =>).
 * If 'link_tooltip' is ommitted then the text is returned witout a wrapping anchor. If 'text' is ommitted then
 * $page is used as the link text.
 *
 * @return themed pager link.
 * @see garland_pager_link()
 */
function garland_simple_pager_link($base_url, $page, $button_attributes) {

  $text = isset($button_attributes['text']) ? $button_attributes['text'] : $page;

  $attributes = array(
      'title' => (isset($button_attributes['link_tooltip']) ? $button_attributes['link_tooltip'] : ''),
  );
  if (isset($button_attributes['class']))
    $attributes['class'] = $button_attributes['class'];

  if (isset($button_attributes['link_tooltip'])) {
    return '<a href="'. check_url(url($base_url, array('query' => array('page' => $page)))) .'"'. drupal_attributes($attributes) .'>'. $text .'</a>';
  } else {
    return $text;
  }
}


// Amend you theme's theme() method accordingly, as I've done below for Garland:

function garland_theme($existing, $type, $theme, $path) {
  return array(
    'simple-pager-links' => array(
      'arguments' => array(NULL, NULL, NULL, NULL),
      'function' => 'garland_simple_pager_links',
    ),
    'simple-pager-link' => array(
      'arguments' => array(NULL, NULL, NULL),
      'function' => 'garland_simple_pager_link',
    )
  );
}

Revision: 30723
at August 25, 2010 00:59 by hiddentao


Updated Code
/**
 * Return themed pager using same markup and CSS classes as the standard Drupal pager.
 *
 * @param  $total_pages total no. of pages.
 * @param  $current_page the current page being viewed (1 <= $current_page <= $total_pages).
 * @param  $num_page_links_either_side no. of pages links to show either side of the current page's item.
 * @param  $base_url the base URL for paging links. Each paging link will be at $base_url?page=<page_num>
 * @return themed paging links; empty string if there is only one page in total.
 */
function garland_simple_pager_links($total_pages, $current_page, $num_page_links_either_side, $base_url) {

  static $buttons;
  if (empty($buttons)) {
    $buttons = array(
      'first' => array('text' => t('&laquo; first'), 'link_tooltip' => t('Go to first page')),
      'prev' => array('text' => t('&lsaquo; previous'), 'link_tooltip' => t('Go to previous page')),
      'next' => array('text' => t('next &rsaquo;'), 'link_tooltip' => t('Go to next page')),
      'last' => array('text' => t('last &raquo;'), 'link_tooltip' => t('Go to last page')),
      'current' => array('class' => 'current'),
      'ellipsis' => array('text' => '...'),
    );
  }

  // show nothing if only one page
  if (1 >= $total_pages)
    return '';

  // remove all query params from the base URL
  $base_url = ltrim($base_url,'/');

  // the first page in current set of pages
  $pager_first = $current_page - $num_page_links_either_side;
  // the last page in current set of pages
  $pager_last = $current_page + $num_page_links_either_side;

  // normalize
  if (1 > $pager_first) {
    $pager_last += (1 - $pager_first);
    $pager_first = 1;
  }
  if ($total_pages < $pager_last) {
    $pager_first -= ($pager_last - $total_pages);
    if (1 > $pager_first)
      $pager_first = 1;
    $pager_last = $total_pages;
  }

  $items = array();

  // show 'prev' button
  if (1 < $current_page) {
    // show 'first' button
    if (1 < $pager_first) {
      $items[] = array(
        'class' => 'pager-first',
        'data' => theme('simple-pager-link', $base_url, 1, $buttons['first']),
      );
    }
    $items[] = array(
      'class' => 'pager-previous',
      'data' => theme('simple-pager-link', $base_url, $current_page-1, $buttons['prev']),
    );
    // show ellipsis
    if (1 < $pager_first) {
      $items[] = array(
        'class' => 'pager-ellipsis',
        'data' => theme('simple-pager-link', $base_url, '...', $buttons['ellipsis']),
      );
    }
  }

  // page links
  for ($i=$pager_first; $i<=$pager_last; ++$i) {
    if ($i == $current_page) {
      $items[] = array(
        'class' => 'pager-current',
        'data' => theme('simple-pager-link', $base_url, $i, $buttons['current']),
      );
    } else {
      $items[] = array(
        'class' => 'pager-item',
        'data' => theme('simple-pager-link', $base_url, $i, array('text' => $i, 'link_tooltip' => t('Goto page @d',array('@d' => $i)))),
      );
    }
  }

  // show 'next' button
  if ($total_pages > $current_page) {
    // show ellipsis
    if ($total_pages > $pager_last) {
      $items[] = array(
        'class' => 'pager-ellipsis',
        'data' => theme('simple-pager-link', $base_url, '...', $buttons['ellipsis']),
      );
    }
    $items[] = array(
      'class' => 'pager-next',
      'data' => theme('simple-pager-link', $base_url, $current_page+1, $buttons['next']),
    );
    // show 'last' button
    if ($total_pages > $pager_last) {
      $items[] = array(
        'class' => 'pager-last',
        'data' => theme('simple-pager-link', $base_url, $total_pages, $buttons['last']),
      );
    }
  }

  return theme('item_list', $items, NULL, 'ul', array('class' => 'pager'));
}


/**
 * Return a themed pager link.
 *
 * @param  $base_url the base URL to add the paging query param to.
 * @param  $page the number of the page to link to.
 * @param  $button_attributes array('link_tooltip' =>, 'text' => 'class' =>).
 * If 'link_tooltip' is ommitted then the text is returned witout a wrapping anchor. If 'text' is ommitted then
 * $page is used as the link text.
 *
 * @return themed pager link.
 */
function garland_simple_pager_link($base_url, $page, $button_attributes) {

  $text = isset($button_attributes['text']) ? $button_attributes['text'] : $page;

  $attributes = array(
      'title' => (isset($button_attributes['link_tooltip']) ? $button_attributes['link_tooltip'] : ''),
  );
  if (isset($button_attributes['class']))
    $attributes['class'] = $button_attributes['class'];

  if (isset($button_attributes['link_tooltip'])) {
    return '<a href="'. check_url(url($base_url, array('query' => array('page' => $page)))) .'"'. drupal_attributes($attributes) .'>'. $text .'</a>';
  } else {
    return $text;
  }
}


// Amend you theme's theme() method accordingly, as I've done below for Garland:

function garland_theme($existing, $type, $theme, $path) {
  return array(
    'simple-pager-links' => array(
      'arguments' => array(NULL, NULL, NULL, NULL),
      'function' => 'garland_simple_pager_links',
    ),
    'simple-pager-link' => array(
      'arguments' => array(NULL, NULL, NULL),
      'function' => 'garland_simple_pager_link',
    )
  );
}

Revision: 30722
at August 25, 2010 00:55 by hiddentao


Updated Code
/**
 * Return themed pager using same markup and CSS classes as the standard Drupal pager.
 *
 * @param  $total_pages total no. of pages.
 * @param  $current_page the current page being viewed (1 <= $current_page <= $total_pages).
 * @param  $num_page_links_either_side no. of pages links to show either side of the current page's item.
 * @param  $base_url the base URL for paging links. Each paging link will be at $base_url?page=<page_num>
 * @return themed paging links; empty string if there is only one page in total.
 */
function garland_simple_pager_links($total_pages, $current_page, $num_page_links_either_side, $base_url) {

  static $buttons;
  if (empty($buttons)) {
    $buttons = array(
      'first' => array('text' => t('&laquo; first'), 'link_tooltip' => t('Go to first page')),
      'prev' => array('text' => t('&lsaquo; previous'), 'link_tooltip' => t('Go to previous page')),
      'next' => array('text' => t('next &rsaquo;'), 'link_tooltip' => t('Go to next page')),
      'last' => array('text' => t('last &raquo;'), 'link_tooltip' => t('Go to last page')),
      'current' => array('class' => 'current'),
      'ellipsis' => array('text' => '...'),
    );
  }

  // show nothing if only one page
  if (1 >= $total_pages)
    return '';

  // remove all query params from the base URL
  $base_url = ltrim($base_url,'/');

  // the first page in current set of pages
  $pager_first = $current_page - $num_page_links_either_side;
  // the last page in current set of pages
  $pager_last = $current_page + $num_page_links_either_side;

  // normalize
  if (1 > $pager_first) {
    $pager_last += (1 - $pager_first);
    $pager_first = 1;
  }
  if ($total_pages < $pager_last) {
    $pager_first -= ($pager_last - $total_pages);
    if (1 > $pager_first)
      $pager_first = 1;
    $pager_last = $total_pages;
  }

  $items = array();

  // show 'prev' button
  if (1 < $current_page) {
    // show 'first' button
    if (1 < $pager_first) {
      $items[] = array(
        'class' => 'pager-first',
        'data' => theme('simple-pager-link', $base_url, 1, $buttons['first']),
      );
    }
    $items[] = array(
      'class' => 'pager-previous',
      'data' => theme('simple-pager-link', $base_url, $current_page-1, $buttons['prev']),
    );
    // show ellipsis
    if (1 < $pager_first) {
      $items[] = array(
        'class' => 'pager-ellipsis',
        'data' => theme('simple-pager-link', '...', $base_url, $buttons['ellipsis']),
      );
    }
  }

  // page links
  for ($i=$pager_first; $i<=$pager_last; ++$i) {
    if ($i == $current_page) {
      $items[] = array(
        'class' => 'pager-current',
        'data' => theme('simple-pager-link', $base_url, $i, $buttons['current']),
      );
    } else {
      $items[] = array(
        'class' => 'pager-item',
        'data' => theme('simple-pager-link', $base_url, $i, array('text' => $i, 'link_tooltip' => t('Goto page @d',array('@d' => $i)))),
      );
    }
  }

  // show 'next' button
  if ($total_pages > $current_page) {
    // show ellipsis
    if ($total_pages > $pager_last) {
      $items[] = array(
        'class' => 'pager-ellipsis',
        'data' => theme('simple-pager-link', '...', $base_url, $buttons['ellipsis']),
      );
    }
    $items[] = array(
      'class' => 'pager-next',
      'data' => theme('simple-pager-link', $base_url, $current_page+1, $buttons['next']),
    );
    // show 'last' button
    if ($total_pages > $pager_last) {
      $items[] = array(
        'class' => 'pager-last',
        'data' => theme('simple-pager-link', $base_url, $total_pages, $buttons['last']),
      );
    }
  }

  return theme('item_list', $items, NULL, 'ul', array('class' => 'pager'));
}


/**
 * Return a themed pager link.
 *
 * @param  $base_url the base URL to add the paging query param to.
 * @param  $page the number of the page to link to.
 * @param  $button_attributes array('link_tooltip' =>, 'text' => 'class' =>).
 * If 'link_tooltip' is ommitted then the text is returned witout a wrapping anchor. If 'text' is ommitted then
 * $page is used as the link text.
 *
 * @return themed pager link.
 */
function garland_simple_pager_link($base_url, $page, $button_attributes) {

  $text = isset($button_attributes['text']) ? $button_attributes['text'] : $page;

  $attributes = array(
      'title' => (isset($button_attributes['link_tooltip']) ? $button_attributes['link_tooltip'] : ''),
  );
  if (isset($button_attributes['class']))
    $attributes['class'] = $button_attributes['class'];

  if (isset($button_attributes['link_tooltip'])) {
    return '<a href="'. check_url(url($base_url, array('query' => array('page' => $page)))) .'"'. drupal_attributes($attributes) .'>'. $text .'</a>';
  } else {
    return $text;
  }
}


// Amend you theme's theme() method accordingly, as I've done below for Garland:

function garland_theme($existing, $type, $theme, $path) {
  return array(
    'simple-pager-links' => array(
      'arguments' => array(NULL, NULL, NULL, NULL),
      'function' => 'garland_simple_pager_links',
    ),
    'simple-pager-link' => array(
      'arguments' => array(NULL, NULL, NULL),
      'function' => 'garland_simple_pager_link',
    )
  );
}

Revision: 30721
at August 23, 2010 07:17 by hiddentao


Updated Code
/**
 * Return themed pager using same markup and CSS classes as the standard Drupal pager.
 *
 * @param  $total_pages total no. of pages.
 * @param  $current_page the current page being viewed (1 <= $current_page <= $total_pages).
 * @param  $num_page_links_either_side no. of pages links to show either side of the current page's item.
 * @param  $base_url the base URL for paging links. Each paging link will be at $base_url?page=<page_num>
 * @return themed paging links; empty string if there is only one page in total.
 */
function garland_simple_pager_links($total_pages, $current_page, $num_page_links_either_side, $base_url) {

  static $buttons;
  if (empty($buttons)) {
    $buttons = array(
      'first' => array('text' => t('&laquo; first'), 'link_tooltip' => t('Go to first page')),
      'prev' => array('text' => t('&lsaquo; previous'), 'link_tooltip' => t('Go to previous page')),
      'next' => array('text' => t('next &rsaquo;'), 'link_tooltip' => t('Go to next page')),
      'last' => array('text' => t('last &raquo;'), 'link_tooltip' => t('Go to last page')),
      'current' => array('class' => 'current'),
      'ellipsis' => array('text' => '...'),
    );
  }

  // show nothing if only one page
  if (1 >= $total_pages)
    return '';

  // remove all query params from the base URL
  $base_url = ltrim($base_url,'/');

  // we try and keep the current page in the middle of set of pager links
  $pager_current = $current_page;
  // the first page in current set of pages
  $pager_first = $current_page - $num_page_links_either_side;
  // the last page in current set of pages
  $pager_last = $current_page + $num_page_links_either_side;

  // normalize
  if (1 > $pager_first) {
    $pager_last += (1 - $pager_first);
    $pager_first = 1;
  }
  if ($total_pages < $pager_last) {
    $pager_first -= ($pager_last - $total_pages);
    if (1 > $pager_first)
      $pager_first = 1;
    $pager_last = $total_pages;
  }

  $items = array();

  // show 'prev' button
  if (1 < $current_page) {
    // show 'first' button
    if (1 < $pager_first) {
      $items[] = array(
        'class' => 'pager-first',
        'data' => theme('simple-pager-link', $base_url, 1, $buttons['first']),
      );
    }
    $items[] = array(
      'class' => 'pager-previous',
      'data' => theme('simple-pager-link', $base_url, $current_page-1, $buttons['prev']),
    );
    // show ellipsis
    if (1 < $pager_first) {
      $items[] = array(
        'class' => 'pager-ellipsis',
        'data' => theme('simple-pager-link', '...', $base_url, $buttons['ellipsis']),
      );
    }
  }

  // page links
  for ($i=$pager_first; $i<=$pager_last; ++$i) {
    if ($i == $pager_current) {
      $items[] = array(
        'class' => 'pager-current',
        'data' => theme('simple-pager-link', $base_url, $i, $buttons['current']),
      );
    } else {
      $items[] = array(
        'class' => 'pager-item',
        'data' => theme('simple-pager-link', $base_url, $i, array('text' => $i, 'link_tooltip' => t('Goto page @d',array('@d' => $i)))),
      );
    }
  }

  // show 'next' button
  if ($total_pages > $current_page) {
    // show ellipsis
    if ($total_pages > $pager_last) {
      $items[] = array(
        'class' => 'pager-ellipsis',
        'data' => theme('simple-pager-link', '...', $base_url, $buttons['ellipsis']),
      );
    }
    $items[] = array(
      'class' => 'pager-next',
      'data' => theme('simple-pager-link', $base_url, $current_page+1, $buttons['next']),
    );
    // show 'last' button
    if ($total_pages > $pager_last) {
      $items[] = array(
        'class' => 'pager-last',
        'data' => theme('simple-pager-link', $base_url, $total_pages, $buttons['last']),
      );
    }
  }

  return theme('item_list', $items, NULL, 'ul', array('class' => 'pager'));
}


/**
 * Return a themed pager link.
 *
 * @param  $base_url the base URL to add the paging query param to.
 * @param  $page the number of the page to link to.
 * @param  $button_attributes array('link_tooltip' =>, 'text' => 'class' =>).
 * If 'link_tooltip' is ommitted then the text is returned witout a wrapping anchor. If 'text' is ommitted then
 * $page is used as the link text.
 *
 * @return themed pager link.
 */
function garland_simple_pager_link($base_url, $page, $button_attributes) {

  $text = isset($button_attributes['text']) ? $button_attributes['text'] : $page;

  $attributes = array(
      'title' => (isset($button_attributes['link_tooltip']) ? $button_attributes['link_tooltip'] : ''),
  );
  if (isset($button_attributes['class']))
    $attributes['class'] = $button_attributes['class'];

  if (isset($button_attributes['link_tooltip'])) {
    return '<a href="'. check_url(url($base_url, array('query' => array('page' => $page)))) .'"'. drupal_attributes($attributes) .'>'. $text .'</a>';
  } else {
    return $text;
  }
}


// Amend you theme's theme() method accordingly, as I've done below for Garland:

function garland_theme($existing, $type, $theme, $path) {
  return array(
    'simple-pager-links' => array(
      'arguments' => array(NULL, NULL, NULL, NULL),
      'function' => 'garland_simple_pager_links',
    ),
    'simple-pager-link' => array(
      'arguments' => array(NULL, NULL, NULL),
      'function' => 'garland_simple_pager_link',
    )
  );
}

Revision: 30720
at August 20, 2010 02:39 by hiddentao


Initial Code
/**
 * Return themed pager using same markup and CSS classes as the standard Drupal pager.
 *
 * @param  $total_pages total no. of pages.
 * @param  $current_page the current page being viewed (1 <= $current_page <= $total_pages).
 * @param  $num_page_links_either_side no. of pages links to show either side of the current page's item.
 * @param  $base_url the base URL for paging links. Each paging link will be at $base_url?page=<page_num>
 * @return themed paging links; empty string if there is only one page in total.
 */
function garland_simple_pager_links($total_pages, $current_page, $num_page_links_either_side, $base_url) {

  static $buttons;
  if (empty($buttons)) {
    $buttons = array(
      'first' => array('text' => t('&laquo; first'), 'link_tooltip' => t('Go to first page')),
      'prev' => array('text' => t('&lsaquo; previous'), 'link_tooltip' => t('Go to previous page')),
      'next' => array('text' => t('next &rsaquo;'), 'link_tooltip' => t('Go to next page')),
      'last' => array('text' => t('last &raquo;'), 'link_tooltip' => t('Go to last page')),
      'current' => array('class' => 'current'),
      'ellipsis' => array('text' => '...'),
    );
  }

  // show nothing if only one page
  if (1 >= $total_pages)
    return '';

  // remove all query params from the base URL
  $base_url = ltrim($base_url,'/');

  // we try and keep the current page in the middle of set of pager links
  $pager_current = $current_page;
  // the first page in current set of pages
  $pager_first = $current_page - $num_page_links_either_side;
  // the last page in current set of pages
  $pager_last = $current_page + $num_page_links_either_side;

  // normalize
  if (1 > $pager_first) {
    $pager_last += (1 - $pager_first);
    $pager_first = 1;
  }
  if ($total_pages < $pager_last) {
    $pager_first -= ($pager_last - $total_pages);
    if (1 > $pager_first)
      $pager_first = 1;
    $pager_last = $total_pages;
  }

  $items = array();

  // show 'prev' button
  if (1 < $current_page) {
    // show 'first' button
    if (1 < $pager_first) {
      $items[] = array(
        'class' => 'pager-first',
        'data' => theme('simple-pager-link', $base_url, 1, $buttons['first']),
      );
    }
    $items[] = array(
      'class' => 'pager-previous',
      'data' => theme('simple-pager-link', $base_url, $current_page-1, $buttons['prev']),
    );
    // show ellipsis
    if (1 < $pager_first) {
      $items[] = array(
        'class' => 'pager-ellipsis',
        'data' => theme('simple-pager-link', '...', $base_url, $buttons['ellipsis']),
      );
    }
  }

  // page links
  for ($i=$pager_first; $i<=$pager_last; ++$i) {
    if ($i == $pager_current) {
      $items[] = array(
        'class' => 'pager-current',
        'data' => theme('simple-pager-link', $base_url, $i, $buttons['current']),
      );
    } else {
      $items[] = array(
        'class' => 'pager-item',
        'data' => theme('simple-pager-link', $base_url, $i, array('text' => $i, 'link_tooltip' => t('Goto page @d',array('@d' => $i)))),
      );
    }
  }

  // show 'next' button
  if ($total_pages > $current_page) {
    // show ellipsis
    if ($total_pages > $pager_last) {
      $items[] = array(
        'class' => 'pager-ellipsis',
        'data' => theme('simple-pager-link', '...', $base_url, $buttons['ellipsis']),
      );
    }
    $items[] = array(
      'class' => 'pager-next',
      'data' => theme('simple-pager-link', $base_url, $current_page+1, $buttons['next']),
    );
    // show 'last' button
    if ($total_pages > $pager_last) {
      $items[] = array(
        'class' => 'pager-last',
        'data' => theme('simple-pager-link', $base_url, $total_pages, $buttons['last']),
      );
    }
  }

  return theme('item_list', $items, NULL, 'ul', array('class' => 'pager'));
}


/**
 * Return a themed pager link.
 *
 * @param  $base_url the base URL to add the paging query param to.
 * @param  $page the number of the page to link to.
 * @param  $button_attributes array('link_tooltip' =>, 'text' => 'class' =>).
 * If 'link_tooltip' is ommitted then the text is returned witout a wrapping anchor. If 'text' is ommitted then
 * $page is used as the link text.
 *
 * @return themed pager link.
 * @see garland_pager_link()
 */
function garland_simple_pager_link($base_url, $page, $button_attributes) {

  $text = isset($button_attributes['text']) ? $button_attributes['text'] : $page;

  $attributes = array(
      'title' => (isset($button_attributes['link_tooltip']) ? $button_attributes['link_tooltip'] : ''),
  );
  if (isset($button_attributes['class']))
    $attributes['class'] = $button_attributes['class'];

  if (isset($button_attributes['link_tooltip'])) {
    return '<a href="'. check_url(url($base_url, array('query' => array('page' => $page)))) .'"'. drupal_attributes($attributes) .'>'. $text .'</a>';
  } else {
    return $text;
  }
}


// Amend you theme's theme() method accordingly, as I've done below for Garland:

function garland_theme($existing, $type, $theme, $path) {
  return array(
    'simple-pager-links' => array(
      'arguments' => array(NULL, NULL, NULL, NULL),
      'function' => 'garland_simple_pager_links',
    ),
    'simple-pager-link' => array(
      'arguments' => array(NULL, NULL, NULL),
      'function' => 'garland_simple_pager_link',
    )
  );
}

Initial URL


Initial Description
All code should ideally go into your theme\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'s template.php file. I\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'ve used the default Garland theme here as an example.

Initial Title
Simple pager script for Drupal 6

Initial Tags
php, drupal

Initial Language
PHP