Jump to:

23379 Posts in 18298 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Conditional operator using $Pos

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

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

Page: 1
Go to End
Author Topic: 1027 Views
  • dezmond
    Avatar
    Community Member
    17 Posts

    Conditional operator using $Pos Link to this post

    Hi,

    Shoukld be so simple but can anyone spot what i'm doing wrong here using $Pos. On the 3rd element i want to apply the class of "last" (which basically gives the Li a right margin of 0).

    <ul class="gallery">
       <% control LatestGalleryItems %>
                       
          <% if $Pos==3 %>
             <li class="last">
          <% else %>
        <li>
          <% end_if %>
       
           <a href="$Large.Link">$Thumbnail</a><p>$Caption</p>
             </li>   
    <% end_control %>
    </ul>

    Many thanks

  • dezmond
    Avatar
    Community Member
    17 Posts

    Re: Conditional operator using $Pos Link to this post

    just realised. It should be <% if Pos==3 %> not <% if $Pos==3 %>

    1027 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.