你现在的位置:首页 > PHP网站建设知识库 > Drupal > 正文

获取drupal路径别名的函数 -- drupal_get_path_alias()

includes/path.inc ,行96

版本
4.6 – 5
drupal_get_path_alias($path)
6 – 7
<a href="http://api.drupal.org/api/function/drupal_get_path_alias/7">drupal_get_path_alias($path,</a> $path_language $ path_language= '') = '' )
鉴于内部Drupal路径,返回别名设定的管理员。

参数

$path  内部Drupal路径。

返回值

一个路径的别名如果被创建,或原始路径如果别名没有被创建。

drupal_get_path_alias ( )

 

代码

<span class="php-boundry">&lt;?php
</span><span class="php-keyword">function</span> <span><a class="local active" title="Given an internal Drupal path, return the alias set by the administrator." href="http://api.drupal.org/api/function/drupal_get_path_alias/5">drupal_get_path_alias</a></span>(<span class="php-variable">$path</span>) {
  <span class="php-variable">$result</span> = <span class="php-variable">$path</span>;
  <span class="php-keyword">if</span> (<span class="php-variable">$alias</span> = <span class="php-function-or-constant"><a class="local" title="Given an alias, return its Drupal system URL if one exists. Given a Drupal
system URL return one of its aliases if such a one exists. Otherwise,
return FALSE." href="http://api.drupal.org/api/function/drupal_lookup_path/5"><u><font color="#0000ff">drupal_lookup_path</font></u></a></span>(<span class="php-string">'alias'</span>, <span class="php-variable">$path</span>)) {
    <span class="php-variable">$result</span> = <span class="php-variable">$alias</span>;
  }
  <span class="php-keyword">if</span> (<a class="php-manual" title="bool function_exists(string function_name)  
     Checks if the function exists" href="http://php.net/function_exists"><u><font color="#0000ff">function_exists</font></u></a>(<span class="php-string">'custom_url_rewrite'</span>)) {
    <span class="php-variable">$result</span> = <span class="php-function-or-constant"><a class="local" title="custom_url_rewrite is not a hook. It is a function you can add to settings.php to manage aliases with some code." href="http://api.drupal.org/api/function/custom_url_rewrite/5"><u><font color="#0000ff">custom_url_rewrite</font></u></a></span>(<span class="php-string">'alias'</span>, <span class="php-variable">$result</span>, <span class="php-variable">$path</span>);
  }
  <span class="php-keyword">return</span> <span class="php-variable">$result</span>;
}
<span class="php-boundry">?&gt;</span>