Dynamic Menu System

HBK

New Member
I am working on a dynamic menu system as the site I'm build has a strict naming convention.For example, if I have a script are named \[code\]AboutUs.php\[/code\], then 'About Us' will be a Parent Menu Item. However if I have a script named \[code\]Product.Product1.php\[/code\] then 'Product' is the Parent Item with 'Product1' as the Sub Menu Item.The idea is to loop through grabbing all the scripts in my frontend folder and build an array so the ul/li elements can be echoed using a nested \[code\]foreach\[/code\]I just can't seem to get the \[code\]Array\[/code\] and the \[code\]$submenu)\[/code\] just right.. Thanks!\[code\]if ($handle = opendir('frontend/')) {while(false !== ($sFile = readdir($handle))) { if (strrpos($sFile, ".php") === strlen($sFile)-strlen(".php")) { $pos1 = strrpos($sFile, "."); $menu = substr($sFile, 0, $pos1); $pos2 = strrpos($sFile, ".php"); if ($pos1 == $pos2) { // "." and ".php" where in the pos, skip submenu $links[$menu] = 'fontend/'.$sFile; } else { $submenu = substr($sFile, $pos1, $pos2); $links[$menu][$submenu] = 'fontend/'.$sFile; } }}\[/code\]}
 
Back
Top