1 path.inc | _path_load_loosely_by_source($source, $langcode = LANGUAGE_NONE) |
Fetches an existing URL alias given a path and optional language.
Parameters
$source: An internal Backdrop path.
$langcode: An optional language code to look up the path in.
Return value
FALSE if no alias was found or an associative array containing the: following keys:
- pid: Unique URL alias identifier.
- alias: The URL alias.
File
- core/
modules/ path/ path.inc, line 65 - Miscellaneous functions for Path module.
Code
function _path_load_loosely_by_source($source, $langcode = LANGUAGE_NONE) {
$pid = db_query_range("SELECT pid FROM {url_alias} WHERE source = :source AND langcode IN (:langcode, :language_none) ORDER BY langcode DESC, pid DESC", 0, 1, array(':source' => $source, ':langcode' => $langcode, ':language_none' => LANGUAGE_NONE))->fetchField();
return path_load(array('pid' => $pid));
}