pager_link

Format a link to a specific query result page.

Parameters

$from_new: The first result to display on the linked page.

$element: An optional integer to distinguish between multiple pagers on one page.

$attributes: An associative array of query string parameters to append to the pager link.

Return value

An HTML string that generates the link.

4 calls to pager_link()

File

includes/pager.inc, line 382
Functions to aid in presenting database results as a set of pages.

Code

function pager_link($from_new, $element, $attributes = array()) {
  $q = $_GET['q'];
  $from = array_key_exists('from', $_GET) ? $_GET['from'] : '';

  foreach ($attributes as $key => $value) {
    $query[] = $key . '=' . $value;
  }

  $from_new = pager_load_array($from_new[$element], $element, explode(',', $from));
  if (count($attributes)) {
    $url = url($q, 'from=' . implode($from_new, ',') . '&' . implode('&', $query));
  }
  else {
    $url = url($q, 'from=' . implode($from_new, ','));
  }

  return check_url($url);
}
Login or register to post comments