Hi guys,
I'm new to Silverstripe so please bear with me if my questions are obvious.
I'm trying to create a two menu structures - one for the header and one for the footer. At a particular stage in each of these menus, I need to know which position I am at and make conditional decisions based on this. For example, if I am at Pos = 3 in a particular control block, then I want to add an extra class to the element I'm displaying. Is there a way to do this using control block code?
Another option for me is to extend the ViewableData class in order to add some custom functions to it. For example, I want to create a function similar to "Last" which is called "SecondLast" and does the same as "Last", except subtracts 2 instead of 1. Ideally I'd like to do this in a child class so I don't touch the Silverstripe core files. Is there a way I could implement this and then run the code block (see below):
<div id="footer-inner" class="clearfix">
<% control Page(footer) %>
<% if Children %>
<h5 class="acc">Footer Menu</h5>
<ul class="clearfix">
<% control Children %>
<li <% if First || SecondLast %> class="separate" <% end_if %>><a href="$Link">$MenuTitle</a></li>
<% end_control %>
</ul>
<% end_if %>
<% end_control %>
</div>
Any help is much appreciated. Thanks :)
Christian