Jump to content

help with building multilevel sitemap from menus


lordrt

Recommended Posts

hello, I have the following code written very long ago by another person, where the aim is to get the parent child hierarchy to build a sitemap.

 

However, I need to modify this code so that it can display the hierarchy as parent-child-subchild, and so far all attempts have failed on my side.

 

I could only get to the display of the child, by uncommenting the code echo $childMenu['TITLE'] at the end of this code, but am not able to get to display the subchild with its link. I tried to do another for loop using the childMenu part but ended up with many errors.

 

anyone can help me with this?



<div id="map-view">	
	<table class="map-view">
		<thead>
			<tr>
				<?php
				//show primary menus
				foreach($rootMenus as $rootMenu) {
					$item = cGetItemMenu($_SESSION['IDLANG'], $rootMenu['IDMENU']);
					?>
					<th>
						<?php
							if($item != null)
							{
								
								switch($item[0]['IDITEMTYPE'])
									{
										case 5:
											?>
											<a href="#" onclick="<?php echo $item[0]['CONTENT'];?>"><?php echo $rootMenu['TITLE']; ?></a>
											<?php
											break;
											
										case 6:
											
											//get info if module module											
											$infoModule = cGetInfoModClients($item[0]['IDLINK']);
											
											// check if page exist
											if(!empty($infoModule)) {
												// On contrôle que c'est bien un module
												switch($infoModule[0]['CODE']) {
													case "PATHCONTROLLER" :
														echo getURLRewriting($item[0]['IDITEMTYPE'], $_SESSION['IDLANG'], $infoModule[0]['IDCLIENTMODULE'], $infoModule[0]['NAME'], $rootMenu['TITLE']);
														break;
													case "JSPOPUP" :
														?>
														<a href="#" onclick="<?php echo $infoModule[0]['ACTION'];?>"><?php echo $rootMenu['TITLE']; ?></a>
														<?php
														break;
												}
											}
											break;
											
										default:
											echo getURLRewriting($item[0]['IDITEMTYPE'], $_SESSION['IDLANG'], $item[0]['IDITEM'], $item[0]['TITLETRANSLATION'], $rootMenu['TITLE']);
											break;
									}							
							}
							else {
								echo $rootMenu['TITLE'];
							}
						?>
					</th>
					<?php
				}
				?>
			</tr> <!--end row for primary menus-->
		</thead>
		<tbody>
			<tr>
				<?php
				
				//get child menus of primary menus
				foreach($rootMenus as $rootMenu) {
					?>
					<td>
						<?php
							$childMenus = cGetMenus($idLang, 1, $rootMenu['IDMENU']);
							
							if(!empty($childMenus) && $childMenus != NULL)
							{
								?>
								<table>
								<?php
								foreach($childMenus as $childMenu) {
									$itemChildMenu = cGetItemMenu($_SESSION['IDLANG'], $childMenu['IDMENU']);
									?>
									<tr>
										<td>
										<?php
										if($itemChildMenu != null)
										{
											switch($itemChildMenu[0]['IDITEMTYPE'])
											{
												case 5:
													?>
													<a href="#" onclick="<?php echo $itemChildMenu[0]['CONTENT'];?>"><?php echo $childMenu['TITLE']; ?></a>
													<?php
													break;
													
												default:
													echo getURLRewriting($itemChildMenu[0]['IDITEMTYPE'], $_SESSION['IDLANG'], $itemChildMenu[0]['IDITEM'], $itemChildMenu[0]['TITLETRANSLATION'], $childMenu['TITLE']);
													break;
											}
										}
										else
										{	
											//echo $childMenu['TITLE']."<br />";					
																										
										}
										?>
										</td>
									</tr>
									<?php
								}
								?>
								</table>
								<?php
							}
						?>
					</td>
					<?php
				}
				?>
			</tr>				
		</tbody>
	</table>
	</div>
</div>






Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.