You are here

drupal_get_path_alias 获取当前路径的别名

 Given an internal Drupal path, return the alias set by the administrator.

对于给定的内部Drupal路径,访问管理员设置的别名.
If no path is provided, the function will return the alias of the current page.
如果没有提供路径,这个函数则会返回当前路径的别名.
Parameters
$path An internal Drupal path.
$path 一个内部Drupal路径
$path_language An optional language code to look up the path in.
可选的语言代码,用于限定路径的范围所在
Return value
返回值
An aliased path if one was found, or the original path if no alias was found.
如果找到了别名,就会返回别名,如果没有找到,就会返回原始路径.
 
<?php
functiondrupal_get_path_alias($path = NULL, $path_language = NULL) {
 // If no path is specified, use the current page's path.
 if ($path == NULL) {
    $path = $_GET['q'];
 }
 $result = $path;
 if ($alias = drupal_lookup_path('alias', $path, $path_language)) {
    $result = $alias;
 }
 return$result;
}
?>

Drupal版本: