Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
silentworks committed Dec 9, 2014
2 parents 3c699bf + a689017 commit 8561c78
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ These helpers are listed below.
- urlFor
- siteUrl
- baseUrl
- currentUrl

#### urlFor

Expand Down Expand Up @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions SmartyPlugins/function.currentUrl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: function.currentUrl.php
* Type: function
* Name: currentUrl
* Purpose: outputs url for a function with the defined name method
* version 0.1.3
* package SlimViews
* -------------------------------------------------------------
*/
function smarty_function_currentUrl($params, $template)
{
$appName = isset($params['appname']) ? $params['appname'] : 'default';
$withQueryString = isset($params['queryString']) ? $params['queryString'] : true;

$app = \Slim\Slim::getInstance($appName);
$req = $app->request();
$uri = $req->getUrl() . $req->getPath();

if ($withQueryString) {
$env = $app->environment();

if ($env['QUERY_STRING']) {
$uri .= '?' . $env['QUERY_STRING'];
}
}

return $uri;
}

0 comments on commit 8561c78

Please sign in to comment.