|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
dougmcc1 Smarty n00b
Joined: 20 Sep 2015 Posts: 2
|
Posted: Sun Sep 20, 2015 4:30 am Post subject: How to count number of slashes in URI? |
|
|
How do I use smarty to count the number of slashes in the URI and store it in a variable?
Here is the php code that I need to convert to smarty:
$url_path = $_SERVER['REQUEST_URI'];
$count_of_slashes = count(explode('/', $url_path))-1;
echo $count_of_slashes;
Thanks! |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sun Sep 20, 2015 10:48 pm Post subject: |
|
|
WHY do you need to do it in Smarty to begin with?
Are you trying to pull business logic into presentation layer or what? |
|
Back to top |
|
dougmcc1 Smarty n00b
Joined: 20 Sep 2015 Posts: 2
|
Posted: Mon Sep 21, 2015 5:31 am Post subject: |
|
|
Because the software I'm working its requires it, or else I wouldn't ask
Do you or anyone else have an answer or more questions? |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Sep 22, 2015 12:54 am Post subject: |
|
|
Code: | {$count = $smarty.server.REQUEST_URI|substr_count:'/'} |
use function substr_count as modifier |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|