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

Conditional operator using $Pos


Go to End


2 Posts   1377 Views

Avatar
dezmond

Community Member, 17 Posts

13 August 2010 at 4:20am

Edited: 13/08/2010 4:21am

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

Avatar
dezmond

Community Member, 17 Posts

13 August 2010 at 4:23am

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