Jump to:

23358 Posts in 17875 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » If statement help

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 411 Views
  • lozhowlett
    Avatar
    Community Member
    146 Posts

    If statement help Link to this post

    Guys

    this is probably stupidly simple, but how do I do something different based on what menu item I am in, within the loop.

    Basically the recipes drop down is going to be a "mega menu" where as the rest are just normal drop downs.

    I cant think how to get around this with built in template controls! Help!

    <% control Menu(1) %>   
    <% if Children %>
    <% if $MenuTitle="Recipes" %>

    <% else %>
    <li><a href="$Link" title="Go to the $Title.XML page">$MenuTitle.XML</a>
    <ul class="dropdown1">
    <% control Children %>
    <li><a href="$Link">$MenuTitle</a></li>
    <% end_control %>
    </ul>
    <% end_if %>
    <% else %>
    <li><a href="$Link" title="Go to the $Title.XML page">$MenuTitle.XML</a>
    <% end_if %>
    </li>
    <% end_control %>

  • lozhowlett
    Avatar
    Community Member
    146 Posts

    Re: If statement help Link to this post

    *bump*

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: If statement help Link to this post

    Basically <% if $MenuTitle="Recipes" %>, like in your example, should work - if you're at version 3.0.x that is. In 2.4 it should be <% if MenuTitle = Recipes %>...

    But maybe I didn't understand you correctly, and you want to know howto create that megadropdown?

    411 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.