Silverstripe has helpers for getting the first and last items in a loop as well as the position / count of the current item in the loop.
Though I can't find how to capture when it's the second to last item...
I've tried trivial things (that'd usually work in most languages) such as
<!-- Right now I know the total is 11, so result should be 10 -->
<!-- Total value will always vary so needs to be dynamically worked out -->
<% if $Pos == $TotalItems-1 %>
$Pos
<% end_if %>
&&
<% if $Last-1 %>
$Pos
<% end_if %>
This doesn't work, AFAIK unlike JavaScript or PHP or whatever you can't slap a -1 to get the second to last item in a loop / array.
What would I need to do to accomplish this?