Hi.
I'm trying to apply this to the second tutorial, http://doc.silverstripe.org/doku.php?id=tutorial:2-extending-a-basic-site
My setup is exactly as in the tutorial and for every third news item I would like to add a divider or set a special css class. I just can't figure it out :(
This is how my HomePage.ss looks like:
<div id="NewsWrapper" class="content {$URLSegment}">
<ul id="NewsList">
<% control LatestNews %>
<li class="newsitem">
<h1><a href="$Link" title="Read more on "{$Name}"">$Title</a></h1>
<h3>$Date.Nice</h3>
<p>$Content.FirstParagraph <a href="$Link" title="Read more on "{$Title}"">Read more >></a></p>
</li>
<% end_control %>
</ul>
</div> <!-- end: NewsWrapper -->
In this thread I saw that there is a template variable called $Pos that gives you the current position. However I can't figure out how to use it. It seems logical that I could simply do:
<% control LatestNews %>
<% if (($Pos%3)==0) %>
<li class="newsitem">
<% else %>
<li class="newsitem">
<% end_if %>
<h1><a href="$Link" title="Read more on "{$Name}"">$Title</a></h1>
<h3>$Date.Nice</h3>
<p>$Content.FirstParagraph <a href="$Link" title="Read more on "{$Title}"">Read more >></a></p>
</li>
<% end_control %>
But that gives me a blank page. I can't seem to use it in any way when I combine it with an if statement. It would be awesome if the tutorials also would cover things like this. Tutorials that are more from a designers point of view.
Maybe there is a section in the documentation or tutorials that covers things like this. If not it would be very helpful to collect all these types of tips and tricks so it's easier for a designer to jump straight into using SilverStripe without really having to understand the inner workings of it....
Best
.r