From a689017a90b279b4b3d59283b9d030ede07c9ee1 Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Tue, 9 Dec 2014 23:48:17 +0000 Subject: [PATCH] Added in currentUrl for Smarty and also added into the README --- README.md | 16 ++++++++++++++ SmartyPlugins/function.currentUrl.php | 31 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 SmartyPlugins/function.currentUrl.php diff --git a/README.md b/README.md index 2f1e82d..99a1200 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ These helpers are listed below. - urlFor - siteUrl - baseUrl +- currentUrl #### urlFor @@ -154,6 +155,21 @@ Inside your Smarty template you would write: {baseUrl} + +#### currentUrl + +__Twig__ + +Inside your Twig template you would write: + + {{ currentUrl() }} + +__Smarty__ + +Inside your Smarty template you would write: + + {currentUrl} + ## Authors [Josh Lockhart](https://github.com/codeguy) diff --git a/SmartyPlugins/function.currentUrl.php b/SmartyPlugins/function.currentUrl.php new file mode 100644 index 0000000..a35927b --- /dev/null +++ b/SmartyPlugins/function.currentUrl.php @@ -0,0 +1,31 @@ +request(); + $uri = $req->getUrl() . $req->getPath(); + + if ($withQueryString) { + $env = $app->environment(); + + if ($env['QUERY_STRING']) { + $uri .= '?' . $env['QUERY_STRING']; + } + } + + return $uri; +}