ranlt / smarty-php

Automatically exported from code.google.com/p/smarty-php
0 stars 0 forks source link

foreach loop @last iteration is broken #185

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use Smarty 3.1.17
2. Write a {foreach} loop with at least two items
3. Use $item@last to print "Last" for the last item.

What is the expected output? What do you see instead?
$item@last is not true for the last item in a foreach loop, so "Last" is not 
printed.

What version of the product are you using? On what operating system?
Smarty-3.1.17
Debian Wheezy

Original issue reported on code.google.com by rickinhe...@gmail.com on 27 Mar 2014 at 11:32

GoogleCodeExporter commented 9 years ago
I have to temporarily use this solution... {if $answer@index == 
$answer@total}Last{/if}

Original comment by rickinhe...@gmail.com on 27 Mar 2014 at 11:33

GoogleCodeExporter commented 9 years ago
NOTE: it's important to use an object (stdClass) instead of an array.

Original comment by rickinhe...@gmail.com on 27 Mar 2014 at 11:35

GoogleCodeExporter commented 9 years ago
Please note that Smarty template syntax is not 100% PHP.

The Smarty foreach properties like @total and @last do work on arrays and 
countables but not general objects.

Original comment by Uwe.Tews@googlemail.com on 28 Mar 2014 at 1:47