Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Section Problem

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
novus
Smarty Rookie


Joined: 17 Nov 2003
Posts: 7

PostPosted: Mon Nov 17, 2003 11:18 am    Post subject: Section Problem Reply with quote

May this will be easy but i couldn't resolve it. So i will make a section to show a image gallery. the problem is, that i have to change the section counter too show the gui in the way i like.

for e.g.

i use an array of image objects to iterate over. now i will show 3 images in one table row.

<smarty: section name=counter loop=$Images/>
<tr>

<td>first image<img src=<smarty: $Images[counter]->getPath() /></td>

<td>second image<smarty: $smarty.section.counter.total ++/><img src=<smarty: $Images[counter]->getPath() /></td>

<td>third image<smarty: $smarty.section.counter.total ++/><<img src=<smarty: $Images[counter]->getPath() /></td>
</tr>
<smarty: /section/>

the question now is, is it possible to do somethink like counter++ ???
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Nov 17, 2003 2:58 pm    Post subject: Reply with quote

hi.

I'm not looking too closely at your code, but simple math operations were introduced with 2.6. You can try 2.6.0 RC3 if you want to try them out. You will not be able to use spaces in your math expressions and besides, the way you have written your increment ($smarty.section.counter.total ++) with an intervening space -- is probably not a wise practice anyhow.

Cheers.
Back to top
View user's profile Send private message
novus
Smarty Rookie


Joined: 17 Nov 2003
Posts: 7

PostPosted: Wed Nov 19, 2003 9:52 am    Post subject: Reply with quote

Thank you for your tip. I red that the math operations are not quite good for the performance so i did it with a smarty plugin.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Nov 19, 2003 6:42 pm    Post subject: Reply with quote

Hi novus.

To be Clear: using the math plugin is indeed slower than you'd want--but the builtin math of 2.6.0+ actyually compiles to native php in your template--so it is faster than any plugin can do and more convenient as well.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP