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

Commit 8561c78

Browse files
committed
Merge branch 'develop'
2 parents 3c699bf + a689017 commit 8561c78

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ These helpers are listed below.
8989
- urlFor
9090
- siteUrl
9191
- baseUrl
92+
- currentUrl
9293

9394
#### urlFor
9495

@@ -154,6 +155,21 @@ Inside your Smarty template you would write:
154155

155156
{baseUrl}
156157

158+
159+
#### currentUrl
160+
161+
__Twig__
162+
163+
Inside your Twig template you would write:
164+
165+
{{ currentUrl() }}
166+
167+
__Smarty__
168+
169+
Inside your Smarty template you would write:
170+
171+
{currentUrl}
172+
157173
## Authors
158174

159175
[Josh Lockhart](https://github.com/codeguy)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/*
3+
* Smarty plugin
4+
* -------------------------------------------------------------
5+
* File: function.currentUrl.php
6+
* Type: function
7+
* Name: currentUrl
8+
* Purpose: outputs url for a function with the defined name method
9+
* version 0.1.3
10+
* package SlimViews
11+
* -------------------------------------------------------------
12+
*/
13+
function smarty_function_currentUrl($params, $template)
14+
{
15+
$appName = isset($params['appname']) ? $params['appname'] : 'default';
16+
$withQueryString = isset($params['queryString']) ? $params['queryString'] : true;
17+
18+
$app = \Slim\Slim::getInstance($appName);
19+
$req = $app->request();
20+
$uri = $req->getUrl() . $req->getPath();
21+
22+
if ($withQueryString) {
23+
$env = $app->environment();
24+
25+
if ($env['QUERY_STRING']) {
26+
$uri .= '?' . $env['QUERY_STRING'];
27+
}
28+
}
29+
30+
return $uri;
31+
}

0 commit comments

Comments
 (0)