summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-05-06 15:51:36 +0000
committerDries Buytaert <dries@buytaert.net>2009-05-06 15:51:36 +0000
commitb2d4f129041413a3804de8a8c12662b39651ea38 (patch)
tree9099e22bf9c386ae498be94b65548dfeb562d5c4 /includes
parent511115f6b879c90b1ccdde9484c83eaa7e7bbacf (diff)
downloadbrdo-b2d4f129041413a3804de8a8c12662b39651ea38.tar.gz
brdo-b2d4f129041413a3804de8a8c12662b39651ea38.tar.bz2
- Patch #431976 by mcrittenden, Arancaytar webchick, chx, et al: added a wrapper for ?q=. No tests.
Diffstat (limited to 'includes')
-rw-r--r--includes/path.inc22
1 files changed, 22 insertions, 0 deletions
diff --git a/includes/path.inc b/includes/path.inc
index 1ff9cb36d..b2a4b0ffa 100644
--- a/includes/path.inc
+++ b/includes/path.inc
@@ -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'];
+}