function path_load

path_load($conditions)

Fetches a specific URL alias from the database.

Parameters

$conditions: A string representing the source, a number representing the pid, or an array of query conditions.

Return value

FALSE if no alias was found or an associative array containing the following keys:

  • source: The internal system path.
  • alias: The URL alias.
  • pid: Unique path alias identifier.
  • language: The language of the alias.

File

includes/path.inc, line 404
Functions to handle paths in Drupal, including path aliasing.

Code

function path_load($conditions) {
  if (is_numeric($conditions)) {
    $conditions = array('pid' => $conditions);
  }
  elseif (is_string($conditions)) {
    $conditions = array('source' => $conditions);
  }
  elseif (!is_array($conditions)) {
    return FALSE;
  }
  $select = db_select('url_alias');
  foreach ($conditions as $field => $value) {
    $select->condition($field, $value);
  }
  return $select
  ->fields('url_alias')
    ->execute()
    ->fetchAssoc();
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!path.inc/function/path_load/7.x