Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

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

menu tree trouble


Go to End


6 Posts   2401 Views

Avatar
supermegaultra

Community Member, 33 Posts

10 November 2009 at 3:25pm

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.

Avatar
Willr

Forum Moderator, 5523 Posts

10 November 2009 at 5:23pm

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.

Avatar
Willr

Forum Moderator, 5523 Posts

10 November 2009 at 5:24pm

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.

Avatar
supermegaultra

Community Member, 33 Posts

11 November 2009 at 9:21am

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?

Avatar
supermegaultra

Community Member, 33 Posts

16 November 2009 at 10:33am

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

Avatar
supermegaultra

Community Member, 33 Posts

17 November 2009 at 3:26pm

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?