|
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 |
Shroomz Smarty n00b
Joined: 29 Dec 2018 Posts: 1
|
Posted: Sat Dec 29, 2018 3:52 pm Post subject: Total of "Row Numbers" in tpl? (Hiring/Paid) |
|
|
Hello, I'm using the following code to list IPs in a row incrementally; however, I can't display the total number of rows at the end.
{assign var="ip" value=1}
{foreach from=$with_stateIps item=foo}
{$ip}{assign var="ip" value=$ip+1}) {$foo['ip']}
{/foreach}
Above helps me to list IPs in a row like this
1. XXX.XXX.XXX.XXX
2. XXX.XXX.XXX.XXX
3. XXX.XXX.XXX.XXX
4. XXX.XXX.XXX.XXX
.
.
999. XXX.XXX.XXX.XXX
1000. XXX.XXX.XXX.XXX
But I can't display the total number of rows like
Total: 1000
Could someone please help me out?
There are a couple more things I will request for further development of my website. Such as adding fancy charts, geo-ip integration, separating unique and raw visitors, etc. Please contact me.
Thank you, |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Jan 01, 2019 4:53 am Post subject: |
|
|
Code: | {foreach $var as $value}
{if $value@first}{$i=0}{/if}
{$i++}
…
{if $value@last}Total: $i{/if}
{/foreach} |
Send your regards to PayPal (my nickname @freemail.ru ) |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Jan 08, 2019 2:04 pm Post subject: |
|
|
Be aware that @total is not necessarily available. I.e. if you are looping an iterator or generator. |
|
Back to top |
|
deepvyas Smarty Rookie
Joined: 19 May 2017 Posts: 9 Location: India
|
Posted: Fri Jan 11, 2019 12:30 pm Post subject: Re: |
|
|
Hello,
Greetings!
I can help you further, If still looking for professional ?
Please let me know on same
Best Regards
Deep |
|
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
|