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.

Themes /

Discuss SilverStripe Themes.

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

Problem with interlocking menu


Go to End


2 Posts   1657 Views

Avatar
Nauri2009

Community Member, 1 Post

22 September 2009 at 10:09am

Edited: 22/09/2009 10:13am

Hello! I have a problem. I am still a considerable beginner in the Silverstripe. (And, unfortunately, my English is very bad ...) for a project I need an interlocking menu with 4 levels. Unfortunately, only does not function. Can somebody check my code after mistake? Please, help me!

Thanks.

P.S. My code:

<ul id="Menu2">
		  	<% control Menu(2) %>
  	    		<% if Children %>
			  	    <li class="$LinkingMode"><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levela"><span><em>$MenuTitle</em></span></a>
	  	    	<% else %>
		  			<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levela"><span><em>$MenuTitle</em></span></a>
				<% end_if %>	  
					<% control Children %>
						<% if LinkOrSection = section %>
							<% if Children %>
								<ul class="sub">
									<li class="$LinkingMode"><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levela"><span><em>$MenuTitle</em></span></a>
										<% if LinkOrSection = section %>
												<% if Children %>
													<ul class="sub">
														<li>
															<ul>
																<span class="roundWhite">
																<% control Children %>
																	<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levelb"><span><em>$MenuTitle</em></span></a></li>
																<% end_control %>
																</span>
															</ul>
														 </li>
													</ul>
												 <% end_if %>
										<% end_if %> 
									 </li>
								</ul>
							 <% end_if %>
						<% end_if %> 
					<% end_control %>
			</li> 
  			<% end_control %>
  		</ul>

Avatar
dhensby

Community Member, 253 Posts

22 September 2009 at 11:30am

I havent looked at this in great detail, but one think i notice immediately is that you check if children exist, but then execute the Children control regardless of the check... So, maybe try:

<ul id="Menu2">
	<% control Menu(2) %>
		<% if Children %>
			<li class="$LinkingMode"><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levela"><span><em>$MenuTitle</em></span></a>
		<% control Children %>
			<% if LinkOrSection = section %>
				<% if Children %>
					<ul class="sub">
						<li class="$LinkingMode"><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levela"><span><em>$MenuTitle</em></span></a>
							<% if LinkOrSection = section %>
								<% if Children %>
									<ul class="sub">
										<li>
											<ul>
												<span class="roundWhite">
													<% control Children %>
														<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levelb"><span><em>$MenuTitle</em></span></a></li>
													<% end_control %>
												</span>
											</ul>
										</li>
									</ul>
								<% end_if %>
							<% end_if %>
						</li>
					</ul>
				<% end_if %>
			<% end_if %> 
		<% end_control %>
		<% else %>
			<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode levela"><span><em>$MenuTitle</em></span></a>
		<% end_if %>
	</li> 
	<% end_control %>
</ul>