You are here

function node_pathauto_page in Pathauto 5

Menu callback; presents a listing of all nodes matching an alias prefix

File

./pathauto_node.inc, line 297

Code

function node_pathauto_page() {
  $prefix = '';
  $lastalpha = '';

  // Skip first two components, which will always be "pathauto/node"
  for ($i = 2; arg($i); $i++) {
    $prefix .= arg($i) . '/';
    if (preg_match('/[a-z]/i', arg($i))) {
      $lastalpha = arg($i);
    }
  }
  if ($lastalpha) {
    $pagetitle = check_plain(drupal_ucfirst($lastalpha));
  }
  else {
    $pagetitle = 'Listing';
  }
  $result = pager_query(db_rewrite_sql("SELECT n.nid FROM {url_alias} a INNER JOIN {node} n ON a.src = CONCAT('node/', n.nid)  WHERE n.status = 1 AND a.dst LIKE '%s%%' ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $prefix);
  $output = '';
  while ($node = db_fetch_object($result)) {
    $output .= node_view(node_load($node->nid), 1);
  }
  $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
  drupal_set_title(t($pagetitle));
  return $output;
}