- Patch #431976 by mcrittenden, Arancaytar webchick, chx, et al: added a wrapper for ?q=. No tests.
parent
511115f6b8
commit
b2d4f12904
|
@ -262,3 +262,25 @@ function drupal_match_path($path, $patterns) {
|
|||
}
|
||||
return (bool)preg_match($regexps[$patterns], $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current URL path of the page being viewed.
|
||||
*
|
||||
* Examples:
|
||||
* - http://example.com/node/306 returns "node/306".
|
||||
* - http://example.com/drupalfolder/node/306 returns "node/306" while
|
||||
* base_path() returns "/drupalfolder/".
|
||||
* - http://example.com/path/alias (which is a path alias for node/306) returns
|
||||
* "node/306" as opposed to the path alias.
|
||||
*
|
||||
* This function is not available in hook_boot() so use $_GET['q'] instead.
|
||||
* However, be careful when doing that because in the case of Example #3
|
||||
* $_GET['q'] will contain "path/alias". If "node/306" is needed, calling
|
||||
* drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH) makes this function available.
|
||||
*
|
||||
* @return
|
||||
* The current Drupal URL path.
|
||||
*/
|
||||
function current_path() {
|
||||
return $_GET['q'];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue