GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   SMARTY HELP: how to print a number for -foreach- (https://gfy.com/showthread.php?t=1035907)

gleem 08-28-2011 09:27 AM

SMARTY HELP: how to print a number for -foreach-
 
If am doing a "foreach" and this is the foreach statement... how do I get smarty to out put a count number for each "foreach" it outputs?

here's the smarty foreach statement I'm using in my CARMA template:

PHP Code:

{foreach from=$carma_comments item=comments

Basically just want to show the comment number on a particular gallery and since it stores the comment ID as overall sitewide comment there's no comment number for that gallery in the array.

fris 08-28-2011 09:39 AM

smarty has a counter function

http://www.smarty.net/docsv2/en/lang...nction.counter

gleem 08-28-2011 09:52 AM

Quote:

Originally Posted by fris (Post 18385210)

ahh, I knew I was missing something, thanx :thumbsup

JayS 08-28-2011 10:54 AM

Quote:

Originally Posted by gleem (Post 18385226)
ahh, I knew I was missing something, thanx :thumbsup

If you just need the number of the iteration you can use something like this:

PHP Code:

{foreach from=$carma_comments item=comments name=bla}  
    
Comment #{$smarty.foreach.bla.iteration}
{/foreach} 

More info here: http://www.smarty.net/docsv2/en/lang...nction.foreach

Diomed 08-28-2011 01:54 PM

Thank god I'm on the advertising side of things. :helpme

Fucksakes 08-28-2011 02:19 PM

Quote:

Originally Posted by Diomed (Post 18385692)
Thank god I'm on the advertising side of things. :helpme

always good to know more ;)

gleem 08-28-2011 08:29 PM

Quote:

Originally Posted by Fucksakes (Post 18385734)
always good to know more ;)

No doubt, I do design, marketing, affiliate repping, write articles, html css & push php & smarty code around... just enough to get by at least.

Some people do 1 thing great, I do many things good, and a few things above or below average.


All times are GMT -7. The time now is 11:30 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc