Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Problem with control Menu(1) and (2)

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

Page: 1
Go to End
Author Topic: 1950 Views
  • mommek
    Avatar
    Community Member
    9 Posts

    Problem with control Menu(1) and (2) Link to this post

    Hello,

    I have somethink like this:

    <% control Menu(1) %>

    <li id="button-$URLSegment"><a href="$Link" title="go to &quot;{$Title}&quot;"></a>

    <% if Menu(2) %>
    <% control Menu(2) %>
    <ul>
    <li><a href="$Link">$MenuTitle</a></li>
    </ul>
    </li>
    <% end_control %>
    <% else %>
    </li>
    <% end_if %>

    <% end_control %>

    but it doesn't work

    I just wanna show sub-menu when I hover main menu:
    (somethink like this: http://www.dynamicdrive.com/style/csslibrary/item/suckertree-menu-horizontal/ )

    Can someone help me?

  • mommek
    Avatar
    Community Member
    9 Posts

    Re: Problem with control Menu(1) and (2) Link to this post

    ok, so I found how works <% children %>..

    <% control Menu(1) %>

    <li id="button-$URLSegment"><a href="$Link" title="go to &quot;{$Title}&quot;"></a>

    <% if Children %>
    <ul>
    <% control Menu(2) %>
    <li><a href="$Link">$MenuTitle</a></li>
    <% end_control %>
    </ul>
    <% end_if %>
    </li>

    <% end_control %>

    ---------------
    but it shows:

    <li id="button-xyz"><a href="/xyz/" title="go to &quot;xyz&quot;"></a>
    <ul>
    <li><a href=""></a></li>
    </ul>
    </li>

    Does someone know why?

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Problem with control Menu(1) and (2) Link to this post

    You cannot use Menu() inside another Menu(). The function Menu is part of the global scope of the templates rather than individual elements. You should use <% if Children %><% control Children %>... when you are inside a menu control and what to show another level.

  • mommek
    Avatar
    Community Member
    9 Posts

    Re: Problem with control Menu(1) and (2) Link to this post

    thanks a lot

    1950 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.