Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba

How to zero index $Pos


Go to End
Reply


5 Posts   616 Views

Avatar
lozhowlett

Community Member, 149 Posts

23 August 2013 at 12:51am

I need to Zero index $Pos as TwitterBootstrap Carousel complains if not!

http://getbootstrap.com/javascript/#carousel

Any idea how I would do this in a loop...

 <% loop SpinnerImages %>
    <li data-target="#homepageSpinner" data-slide-to="$Pos" class="<% if First %>active<% end_if %>"></li>
  <% end_loop %>

Thanks!

Avatar
kinglozzer

Community Member, 183 Posts

23 August 2013 at 3:36am

Try this:

data-slide-to="{$Pos(-1)}"

Avatar
lozhowlett

Community Member, 149 Posts

23 August 2013 at 3:46am

Very randomly that does...

<ol class="carousel-indicators">
    
    <li data-target="#homepageSpinner" data-slide-to="-1" class="active"></li>
    
    <li data-target="#homepageSpinner" data-slide-to="0" class=""></li>
    
  </ol>

Avatar
lozhowlett

Community Member, 149 Posts

23 August 2013 at 3:47am

this works

{$Pos(0)}

Avatar
kinglozzer

Community Member, 183 Posts

23 August 2013 at 10:18pm

Ah sorry, I was thinking that the iterator started at 1:

http://api.silverstripe.org/3.0/source-class-SSViewer_BasicIteratorSupport.html#262-271