lordrt Posted May 3, 2013 Share Posted May 3, 2013 (edited) 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> Edited May 3, 2013 by lordrt Quote Link to comment https://forums.phpfreaks.com/topic/277580-help-with-building-multilevel-sitemap-from-menus/ Share on other sites More sharing options...
lordrt Posted May 3, 2013 Author Share Posted May 3, 2013 managed to solve it, had got one of the variable wrongly named, thus the cause of errors Quote Link to comment https://forums.phpfreaks.com/topic/277580-help-with-building-multilevel-sitemap-from-menus/#findComment-1428005 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.