|
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 |
dygel Smarty n00b
Joined: 22 Nov 2006 Posts: 3
|
Posted: Wed Nov 22, 2006 5:21 pm Post subject: {math} with an array count? |
|
|
I'm doing some screwy work with tabindexes on a form. There's a master section with sub blocks, which are presented below. The sub blocks feed total fields on the master form, so the tabindex path takes you through fields in the master till you get to the total line, drops you down to the sub block, walks you through that, and takes you up to the next line in the master form.
Code side, I'm trying to do some math to advance my tab index count ahead by the number of objects in the array used to build the sub block (in this case $products[1]) plus one.
Trick is, I'm not finding a simple way to do this with out-of-the-box smarty functions. I can't use count(), since this isn't an {if}. I tried using $products[1]|count as a modifier -- that didn't work either.
Anyone have any suggestions or would I be stuck writing a custom function or modifier? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Nov 22, 2006 5:29 pm Post subject: |
|
|
count() should work fine inside {if}. |
|
Back to top |
|
dygel Smarty n00b
Joined: 22 Nov 2006 Posts: 3
|
Posted: Wed Nov 22, 2006 5:35 pm Post subject: |
|
|
messju wrote: | count() should work fine inside {if}. |
Inside {if}, it would. I'm using {math}. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Nov 22, 2006 5:40 pm Post subject: |
|
|
For a modifier, you pass an entire array using @:
{$products[1]|@count} |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Wed Nov 22, 2006 5:44 pm Post subject: |
|
|
dygel wrote: | Inside {if}, it would. I'm using {math}. |
arg! misread the "isn't".
you can do something like: {math equation="a+1" a=$foo|@count} |
|
Back to top |
|
dygel Smarty n00b
Joined: 22 Nov 2006 Posts: 3
|
Posted: Wed Nov 22, 2006 5:54 pm Post subject: |
|
|
boots wrote: | For a modifier, you pass an entire array using @:
{$products[1]|@count} |
That did what I needed. Thanks for the tip. |
|
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
|