Search code examples
loopsif-statementsilverstripesinglepage

SilverStripe: Loop If Statement


I'm building a single page portfolio with SilverStripe.

So far I am able to loop through my sites and all $Title[s] and $Content[s] are visible in one <div>. Now I want to attach a certain CSS-class if the current page (which is looped) is named "Contact".

Something like:

//Pseudocode:
<loop start>
if ($Title == 'Contact') <div class="a"></div> else <div class="b"></div>
<loop end>

Does anybody know how to do this?


Solution

  • <% if $Title == "Contact" %>
         // Do something ...
    <% end_if %>