This repository was archived by the owner on Nov 8, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments