Jump to:

3447 Posts in 1032 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » menu tree trouble

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

Page: 1
Go to End
Author Topic: 1434 Views
  • supermegaultra
    Avatar
    Community Member
    33 Posts

    menu tree trouble Link to this post

    Hi all,

    I'm trying to create a menu tree that displays the links to the children pages directly under the parent link. For example if I clicked on 'tractors/machinery':

    Home.

    Parts/Accessories.

    Tractors/Machinery.
    - New Machinery
    - Used Machinery

    Workshop.

    Contact.

    Here is the code in my .ss file I have at the moment:

    <ul id="Menu1">
    <% control Menu(1) %>
    <li class="$LinkingMode"><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle</a></li>
    <% end_control %>
    </ul>
             
          <% if Menu(2) %>
    <ul id="Menu2">
    <% control Menu(2) %>
    <li class="$LinkingMode"><a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle</a></li>
    <% end_control %>
    </ul>
    <% end_if %>

    Any help?! Cheers.

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: menu tree trouble Link to this post

    Try replacing the <% if Menu(2) %> with <% if LinkOrSection %>. The menu you are trying to achieve is similar to the default theme isn't it? You can use that as a good starting point.

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: menu tree trouble Link to this post

    Try replacing the <% if Menu(2) %> with <% if LinkOrSection %>. The menu you are trying to achieve is similar to the default theme isn't it? You can use that as a good starting point.

  • supermegaultra
    Avatar
    Community Member
    33 Posts

    Re: menu tree trouble Link to this post

    Cheers Willr,

    Yeah I've just been using the menu from the default theme and have edited the CSS so it's styled like a virticle tree style menu. I just tried chaning <% if Menu(2) %> with <% if LinkOrSection %>, still looks the same damnit. Any other advice?

  • supermegaultra
    Avatar
    Community Member
    33 Posts

    Re: menu tree trouble Link to this post

    Hi again, I'm still having trouble with this. Any help please?

  • supermegaultra
    Avatar
    Community Member
    33 Posts

    Re: menu tree trouble Link to this post

    ahhh ha, I've figured out a bit of the problem. My code in my Page.ss is as follows:

    <ul id="Menu1">
    <% control Menu(1) %>
    <li class="$LinkingMode">
        <a href="$Link" title="Go to the &quot;{$Title}&quot; page">$MenuTitle</a>
        </li>
       
              
          <% if LinkOrSection = section %>
    <ul id="Menu2">
              <% control GroupsMenu %>
              <% if Children %>
                  <li class="$LinkingMode">
                   <a href="$Link" title="<% sprintf(_t("GOTOPAGE","Go to the %s page"),$Title.XML) %>" class="$LinkingMode Nobottom">$MenuTitle</a>
               <% else %>
                    <li><a href="$Link" title="<% sprintf(_t("GOTOPAGE"),$Title.XML) %>" class="$LinkingMode">$MenuTitle</a>
                <% end_if %>   
              
                 <% if LinkOrSection = section %>
                    <% if ChildGroups %>
                      <ul class="sub">
                         <li>
                             <ul>
                                <% control ChildGroups %>
                                    <li class="$LinkingMode">
                                       <a href="$Link" title="<% sprintf(_t("GOTOPAGE"),$Title.XML) %>" class="$LinkingMode">$MenuTitle.LimitCharacters(22)</a>
                                  </li>
                                <% end_control %>
                              </ul>
                           </li>
                       </ul>
                     <% end_if %>
                <% end_if %>
             </li>
             <% end_control %>
          </ul>
    <% end_if %>
          
    <% end_control %>
    </ul>

    My only issue is that it now formats like what is found on the left of this page http://www.designalt.co.nz/jml/tractors-machinery/

    How can I make the 'new tractors, used tractors, etc etc..' use the Menu2 CSS formatting?

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