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; +}