I'm currently working on a project with Silverstripe where the client wants to be able to have a nested menu that works for all menu levels, i.e. it doesn't matter if there are 2 or 9 or n levels, they will all be displayed (the design allows for a fairly good amount of levels). All I've seen on the forums or the current themes are hard-coded menus of a fixed maximum depth.
I've tried this:
Nav.ss <% control Menu(1) %> <!-- here the code for the lists, links etc... --> <% include SubNav %> <% end_control %> SubNav.ss <% if Children %> <% control Children %> <!-- here the code for the lists, links etc... --> <% if Children %> <% include SubNav %> <% end_if %> <% end_control %> <% end_if %>
The text in bold is supposed to get the SubNav file to include itself until there are no more children. The problem is that I get an exceeded memory error message. Obviously, the include statements are executed regardless of the ifs, resulting in an endless loop, as stated in this topic: http://silverstripe.com/site-builders-forum/flat/37299
Does anyone have the same problem, or maybe an idea on how to resolve this? Thank you very much in advance!