designrunway
Offline
Posts: 36
|
 |
« Reply #1 on: August 09, 2005, 04:01:05 AM » |
|
Ok
I think I got it. I concede that it might not be the best method, but it worked for me. If any administrators (Ryan?) of this site see this as useful, please feel free to use the below as documentation. I errored on the side of being more thorough. I'll try to explain all of the steps in a manner that even new users should be able to understand.
1). Change Advanced Settings to use Multiple Menus [Settings > Advanced Options] in the Administration Menu 2). Modify info.php [in the template directory] for each template you plan to utilize these submenus. If you plan to create two submenus for each template, you need to specify two ADDITIONAL menus by inserting the following code in info.php. $menu[2]='Menu 2'; $menu[3]='Menu 3'; ..etc 3). Modify the index.php in the root folder using the following code. [In version 2.5.2, lines 396 to 514] - Copy the entire function: // Function to generate menu - Change the variables names found below throughout the function. I did a find, but manually replaced so that I could inspect the code. [Seems silly to mention, but a find and replace if you don't copy and paste into a new file, will change the original Function to generate menu.] - Be careful not to modify other functions or global variables. === [I found it useful to paste the entire function in another page to modify temporarily so as not to affect your site in case of a blunder. Then I copied and pasted back into my index.php file. Making a copy of index.php before this cut and paste operation isn't a bad idea either so as to minimize risk]. Basically I changed the following function names, appending a '2' to each one. For each custom menu you create, you will need to increment this number. ===
// Changed variables page_menu set parent = 7 [change to the pageID of the parent] set menu_number = [change to include items of parent menus. ] item_template menu_header menu_footer default_class current_class query_menu page vars class link values
[Match page_menu# with MENU_NUMBER]
function page_menu2($parent = 7, $menu_number = 1, $item_template2 = '<li[class]>[a][menu_title][/a]</li>', $menu_header2 = '<ul>', $menu_footer2 = '</ul>', $default_class2 = ' class="menu_default"', $current_class2 = ' class="menu_current"', $recurse = LEVEL) { global $database, $admin, $page_id, $page_trail, $default_link, $extra_sql, $extra_where_sql; // Check if we should add menu number check to query if($parent == 7) { $menu_number2 = "menu = '$menu_number2'"; } else { $menu_number = '1'; } // Query pages $query_menu2 = $database->query("SELECT page_id,menu_title,page_title,link,target,level,visibility$extra_sql FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND $menu_number AND $extra_where_sql ORDER BY position ASC"); // Check if there are any pages to show if($query_menu2->numRows() > 0) { // Print menu header echo $menu_header2; // Loop through pages while($page2 = $query_menu2->fetchRow()) { // Create vars $vars2 = array('[class]', '[a]', '[/a]', '[menu_title]', '[page_title]'); // Work-out class if($page2['page_id'] == PAGE_ID) { $class2 = $current_class2; } else { $class2 = $default_class2; } // Check if link is same as first page link, and if so change to WB URL if($page2['link'] == $default_link AND !INTRO_PAGE) { $link2 = WB_URL; } else { $link2 = page_link($page2['link']); } // Create values $values2 = array($class2, '<a href="'.$link2.'" target="'.$page2['target'].'">', '</a>', stripslashes($page2['menu_title']), stripslashes($page2['page_title'])); // Replace vars with value and print echo str_replace($vars2, $values2, $item_template2); // Generate sub-menu if(isset($page_trail[$page2['page_id']])) { page_menu2($page2['page_id'], $menu_number2, $item_template2, $menu_header2, $menu_footer2, $default_class2, $current_class2, $recurse-1); } } // Print menu footer echo $menu_footer2; } }
4). Modify Menu in the respective Template. <?php page_menu(PARENT_PAGE_ID_NUMB ER, MENU_NUMBER); ?> [Users that define additional
5). Save and Ready to Go.
I hope this helps.
|