function current_path

Return the current URL path of the page being viewed.

Examples:

This function is available only after DRUPAL_BOOTSTRAP_FULL.

Return value

The current Drupal URL path.

See also

request_path()

49 calls to current_path()
batch_process in drupal/core/includes/form.inc
Processes the batch.
BlockAccessController::checkAccess in drupal/core/modules/block/lib/Drupal/block/BlockAccessController.php
Performs access checks.
CommonTestController::lActiveClass in drupal/core/modules/system/tests/modules/common_test/lib/Drupal/common_test/Controller/CommonTestController.php
Returns links to the current page, with and without query strings.
CommonTestController::themeLinkActiveClass in drupal/core/modules/system/tests/modules/common_test/lib/Drupal/common_test/Controller/CommonTestController.php
Returns links to the current page, with and without query strings.
contact_mail in drupal/core/modules/contact/contact.module
Implements hook_mail().

... See full list

File

drupal/core/includes/path.inc, line 81
Functions to handle paths in Drupal.

Code

function current_path() {

  // @todo Remove the check for whether the request service exists and the
  // fallback code below, once the path alias logic has been figured out in
  // http://drupal.org/node/1269742.
  if (drupal_container()
    ->isScopeActive('request')) {
    $path = drupal_container()
      ->get('request')->attributes
      ->get('system_path');
    if ($path !== NULL) {
      return $path;
    }
  }

  // If we are outside the request scope, fall back to using the path stored in
  // _current_path().
  return _current_path();
}