function current_path
7.x path.inc | current_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_FULL) makes this function available.
Return value
The current Drupal URL path.
See also
12 calls to current_path()
- drupal_cache_system_paths in drupal-7.x/
includes/ path.inc - Cache system paths for a page.
- drupal_lookup_path in drupal-7.x/
includes/ path.inc - 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.
- drupal_redirect_form in drupal-7.x/
includes/ form.inc - Redirects the user to a URL after a form has been processed.
- drupal_validate_form in drupal-7.x/
includes/ form.inc - Validates user-submitted form data in the $form_state array.
- overlay_drupal_goto_alter in drupal-7.x/
modules/ overlay/ overlay.module - Implements hook_drupal_goto_alter().
File
- drupal-7.x/
includes/ path.inc, line 354 - Functions to handle paths in Drupal, including path aliasing.
Code
function current_path() {
return $_GET['q'];
}