nlandgraf Posted December 11, 2009 Share Posted December 11, 2009 I have a two level menu system that breaks down into "categories" in the code below and would like to add another level above this called "platform". How can I revise this code to add another level to the array? <? if($_REQUEST['item_type']=='G' ) { if($_REQUEST['pfid']) $show = true; else $show = false; } else $show = true; if($show) { ?> <div class="title-menu" > <?=$ObjBox->GetBoxheader();?></div> <ul id="MenuBar2" class="MenuBarVertical"> <? if($_REQUEST['item_type']=='G') $Itemtype = 'G'; else $Itemtype = 'M'; if ($Itemtype=="M") $allgenrelink="index.php?view=catalog&item_type=M"; else if ($Itemtype=="G") $allgenrelink="index.php?view=catalog&item_type=G"; if($_REQUEST['pfid']) { $Platform2Obj = new Platform($_REQUEST['pfid'],$DB); ?> <li class="boxplatformhead"><?=$Platform2Obj->GetTitle();?></li> <? } ?> <li><a href="<?=$allgenrelink?>"><b>All Genres</b></a></li> <? if($_REQUEST['cat_id']) { $currentcatobj = new Category($_REQUEST['cat_id'], $DB); $currentcatparent = $currentcatobj->GetParentid(); } $CategoryObj1 = new Category('', $DB); $CategoryObj = $CategoryObj1->GetAllparentfromItemType($Itemtype,'',''); foreach($CategoryObj as $ObjCategory) { if(count($Platform2Obj) > 0) { if($settings['Safe_Urls']) { $catlink = "GameCatelog/".$Platform2Obj->GetPlatformid()."_".$Platform2Obj->GetTitle()."_".$ObjCategory->GetCategoryid()."_".$ObjCategory->GetCategorynm().".html"; } else { $catlink = "index.php?view=catalog&item_type=".$Itemtype."&pfid=".$Platform2Obj->GetPlatformid()."&cat_id=".$ObjCategory->GetCategoryid(); } } else { if($settings['Safe_Urls']) { $catlink = "Category/GameCatelog/".$ObjCategory->GetCategoryid()."_".$ObjCategory->GetCategorynm().".html"; } else { $catlink = "index.php?view=catalog&item_type=".$Itemtype."&cat_id=".$ObjCategory->GetCategoryid(); } } ?> <li ><a <? if($_REQUEST['cat_id'] == $ObjCategory->GetCategoryid()) { ?>class="current"<? } ?> href="<?=$catlink?>"><?=$ObjCategory->GetCategorynm();?></a></li> <? if($_REQUEST['cat_id'] == $ObjCategory->GetCategoryid()) $currentparent = $_REQUEST['cat_id']; elseif($currentcatparent == $ObjCategory->GetCategoryid()) $currentparent = $currentcatparent; if(($_REQUEST['cat_id'] == $ObjCategory->GetCategoryid() || $currentcatparent == $ObjCategory->GetCategoryid()) && $Itemtype == 'M') { $SubCategoryObj = $CategoryObj1->GetAllfromParent($currentparent); if($SubCategoryObj) { ?> <? foreach($SubCategoryObj as $ObjSubCategory) { if($settings['Safe_Urls']) { $subcatlink = "Category/GameCatelog/".$ObjSubCategory->GetCategoryid()."_".$ObjSubCategory->GetCategorynm().".html"; } else { $subcatlink = "index.php?view=catalog&item_type=".$Itemtype."&cat_id=".$ObjSubCategory->GetCategoryid(); } ?> <li><a href="<?=$subcatlink?>"> <?=$ObjSubCategory->GetCategorynm();?></a></li> <? } ?> <? } } } ?> </ul> </div> <? } ?> Link to comment https://forums.phpfreaks.com/topic/184785-create-multidimensional-array/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.