[Drupal] How to get the real path of a node, no matter it is a path or a url alias

Just test the code as below:

 

[Drupal] How to get the real path of a node, no matter it is a path or a url alias 代码
   
     
$uri = substr (request_uri() , 1 , strlen (request_uri()));
$uri_array = array ();
if ( ! ( $path = drupal_lookup_path( ' source ' , $uri ))) {
$uri_array = explode ( ' / ' , $uri );
}
else {
$uri_array = explode ( ' / ' , $path );
}

var_dump ( $uri_array );

 

Have fun!

你可能感兴趣的:(drupal)