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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

How to zero index $Pos


Go to End


5 Posts   1274 Views

Avatar
lozhowlett

Community Member, 151 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, 187 Posts

23 August 2013 at 3:36am

Try this:

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

Avatar
lozhowlett

Community Member, 151 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, 151 Posts

23 August 2013 at 3:47am

this works

{$Pos(0)}

Avatar
kinglozzer

Community Member, 187 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