The <% if %> control structures with Silverstripe are somewhat limited. Some don't like it - I think it is great. It keeps the presentation code as clean and abstracted from the logic. Your .ss templates are much cleaner (all be it for a mild inconvenience).
So if you can't solve your task with the simple Silverstripe Template logic there is a work around...and it is a perfect solution that I have seen mentioned of the forums a few times.
Basically what you need to do is create a method in your Page class file. (the .php file in the mysite directory/code directory)
1. Create the method in your Page's Controller class:
function checkSomething(){
if (compareThis != compareThat) {
return false;
} else {
return true;
}
}
2. Now that you created the method 'checkSomething' in your class file (example like Page.php). Go back to your .ss template file and you can add something like.
<% if checkSomething %>
<p>Hello World</p>
<% end_if %>
Just with that simple strtucture you can build out whatever you may need as complex as you like it within the Class file. When I first saw this it opened up a whole new world within Silverstripe.