|
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 |
smowtion Smarty n00b
Joined: 13 Mar 2013 Posts: 4
|
Posted: Sun Aug 24, 2014 11:34 am Post subject: Next item in foreach SMARTY 3 |
|
|
hello
I used smarty 3 and i need find next item from foreach but not working with this code
Code: |
{foreach $Products AS $p => $Product}
{$Product.Id} {* Current Product Id *}
{$Products[$p-1].Id} {* Previous Product Id *}
{$Products[$p+1].Id} {* Next Product Id *}
{/foreach}
|
or
Code: |
{section name='p' loop=$Products}
{$Products[p].Id} {* Current Product Id *}
{$Products[p.index_prev].Id} {* Previous Product Id *}
{$Products[p.index_next].Id} {* Next Product Id *}
{/section}
|
data get from mongodb result |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Aug 25, 2014 8:42 pm Post subject: |
|
|
Maybe $Products is a keyed array. So $p+1 does not contain the expected value. |
|
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
|