dfcdev Posted August 18, 2015 Share Posted August 18, 2015 hello, I am hoping someone can help me with this, on my file cat_navbar.php, I have set the parameter "$show_full_tree" to "false" because i do not need to display every single subcategory on my mega menu, but the problem is that the sub categories or child menus aren't visible until the parent menu is clicked upon, I need for all child menus to be displayed at all times in the same manner as when you set the parameter "$show_full_tree" to "true" here's the code and also see attached file as well: <?php/*CATEGORY NAVIGATION BARcat_navbar.phpAdapted from ul_categories and superfish jquery for OSC to CSSreferences:by www.niora.com/css-oscommerce.php $Id: ul_categories.php,v 1.00 2006/04/30 01:13:58 nate_02631 Exp $ Outputs the store category list as a proper unordered list, opening up possibilities to use CSS to style as drop-down/flyout, collapsable or other menu types. osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2006 Nate Welch http://www.natewelch.com Released under the GNU General Public License*/// BEGIN Configuration options // Indicates whether or not to render your entire category list or just the root categories // and the currently selected submenu tree. Rendering the full list is useful for dynamic menu // generation where you want the user to have instant access to all categories. The other option // is the default oSC behaviour, when the subcats aren't available until the parent is clicked. $show_full_tree = false; // This is the CSS *ID* you want to assign to the UL (unordered list) containing // your category menu. Used in conjuction with the CSS list you create for the menu. // This value cannot be blank. $idname_for_menu = 'sf-menu cat'; // see superfish.css // This is the *CLASSNAME* you want to tag a LI to indicate the selected category. // The currently selected category (and its parents, if any) will be tagged with // this class. Modify your stylesheet as appropriate. Leave blank or set to false to not assign a class.//gt $classname_for_selected = 'selected'; $classname_for_selected = 'current'; // see superfish.css // This is the *CLASSNAME* you want to tag a LI to indicate a category has subcategores. // Modify your stylesheet to draw an indicator to show the users that subcategories are // available. Leave blank or set to false to not assign a class. //gt $classname_for_parent = 'parent'; $classname_for_parent = 'current'; //see superfish.css $home_html = ((SUPERFISH_HOME == 'Show') ? '<li><a href="' . tep_href_link(FILENAME_DEFAULT) . '"> <i class="fa fa-home"></i></a></li>' : ''); $contact_html = ((SUPERFISH_CONTACT == 'Show') ? '<ul class="sf-menu contact" style="float:right;"><li><a href="' . tep_href_link(FILENAME_CONTACT_US) . '">' . MODULE_BOXES_MAIN_MENU_BOX_CONTACT_US . '</a></li></ul>' : ''); // This is the HTML that you would like to appear before your categories menu // This is useful for reconciling tables or clearing // floats, depending on your layout needs. Leave blank for no html $before_html = ''. "\n".' <script type="text/javascript">'. "\n".' $(document).ready(function(){'. "\n".' $(\'ul.sf-menu\').superfish({'. "\n".' pathClass: \'current\','. "\n".' delay: \''.SUPERFISH_DELAY.'\','. "\n".' animation: {opacity:\'show\',height:\'show\'},'. "\n".' speed: \''. SUPERFISH_SPEED.'\','. "\n".' autoArrows: \''. SUPERFISH_AUTOARROW.'\','. "\n".' dropShadows: false'. "\n".' });'. "\n".' });'. "\n".' </script>'. "\n".' <div class="cat_navbar">'. "\n".' <div class="wpapper">'. "\n".' <div class="navbar_bg"><ul class="'.$idname_for_menu.' first">'.$home_html.''. "\n"; // ' . MODULE_BOXES_MAIN_MENU_BOX_DEFAULT . ' // This is the HTML that you would like to appear after your categories menu if *not*'.SUPERFISH_DELAY.'\ // displaying in a standard "box". This is useful for reconciling tables or clearing // floats, depending on your layout needs. $after_html = ($oscTemplate->hasBlocks('boxes_cat_menu')) ? ''.$oscTemplate->getBlocks('boxes_cat_menu').'</ul>' : '</ul>'. $contact_html."\n"; $after_html2 = '</div>'. "\n".' </div>'. "\n".' </div>'. "\n"; $title = '';// END Configuration options// Global Variables$GLOBALS['this_level'] = 0;// Initialize HTML and info_box class if displaying inside a box// Generate a bulleted list (uses configuration options above)$categories_string = tep_make_catsf_ullist(); echo $before_html.$title.$categories_string.$after_html.$contact_html.$after_html2; // Create the root unordered listfunction tep_make_catsf_ullist($rootcatid = 0, $maxlevel = 0){ global $idname_for_menu, $cPath_array, $show_full_tree, $languages_id, $oscTemplate; // Modify category query if not fetching all categories (limit to root cats and selected subcat tree) if (!$show_full_tree) { $parent_query = 'AND (c.parent_id = "0"'; if (isset($cPath_array)) { $cPath_array_temp = $cPath_array; foreach($cPath_array_temp AS $key => $value) { $parent_query .= ' OR c.parent_id = "'.$value.'"'; } unset($cPath_array_temp); } $parent_query .= ')'; } else { $parent_query = ''; } $result = tep_db_query('select c.categories_id, cd.categories_name, cd.categories_description, c.categories_image, c.parent_id from ' . TABLE_CATEGORIES . ' c, ' . TABLE_CATEGORIES_DESCRIPTION . ' cd where c.categories_id = cd.categories_id and cd.language_id="' . (int)$languages_id .'" '.$parent_query.' order by sort_order DESC, c.sort_order'); while ($row = tep_db_fetch_array($result)) { $table[$row['parent_id']][$row['categories_id']]['parent'] = $row['parent_id']; $table[$row['parent_id']][$row['categories_id']]['name'] = $row['categories_name']; $table[$row['parent_id']][$row['categories_id']]['descr'] = $row['categories_description']; $table[$row['parent_id']][$row['categories_id']]['image'] = $row['categories_image']; } $output .= '';//gt $output .= '<ul id="'.$idname_for_menu.'">'; $output .= tep_make_catsf_ulbranch($rootcatid, $table, 0, $maxlevel); // Close off nested lists for ($nest = 1; $nest <= $GLOBALS['this_level']; $nest++) { $output .= '</ul>'; } return $output; }// Create the branches of the unordered listfunction tep_make_catsf_ulbranch($parcat, $table, $level, $maxlevel) {$caunt = 0;$caunt_ul = 1;$custom_boxes_html = ''; global $cPath_array, $classname_for_selected, $classname_for_parent, $oscTemplate; if (SUPERFISH_CUSTOM_BOX == 'Custom HTML Box') { $custom_boxes_html = ($oscTemplate->hasBlocks('custom_boxes_html')) ? ''.$oscTemplate->getBlocks('custom_boxes_html').'' : ''; } $list = $table[$parcat]; while(list($key,$val) = each($list)){ if ($GLOBALS['this_level'] != $level) { if ($GLOBALS['this_level'] < $level) { if (($level) ==1) { $elements_count = count($table[$val['parent']]); $output .= "\n".' <div class="cat_panel">'.$custom_boxes_html.'<ul>'; }else{ $output .= "\n".'<ul>'; } } else { $fix = 0; for ($nest = 1; $nest <= ($GLOBALS['this_level'] - $level); $nest++) { if (($level) == 0) { if ($GLOBALS['this_level'] - 1 == $level) { $output .= '</ul></li>'."\n"; }elseif ($GLOBALS['this_level'] == $level) { $output .= '</ul></li><div>'."\n"; }elseif ($GLOBALS['this_level'] - 2 == $level) { if (($GLOBALS['this_level'] - 2 == $level) && $nest = 2) { $output .= '</ul></li></ul></div></li>'."\n"; }else{ $output .= '</ul></li>'."\n"; } }else{ $output .= '</ul></li></div></ul>'."\n"; } }elseif (($level) > 1) { if ($GLOBALS['this_level'] - 1 == $level) { $output .= '</ul></li>'."\n"; }else{ $output .= '</li></ul>'."\n"; } }else{ $output .= '</ul></li>'."\n"; } $fix++; } } }$GLOBALS['this_level'] = $level; if (isset($cPath_array) && in_array($key, $cPath_array) && $classname_for_selected) { $this_cat_class = ' class="'.$classname_for_selected.'"'; } else { $this_cat_class = ''; } if ($GLOBALS['this_level'] == 1) { if ($caunt == SUPERFISH_COLUMN ) { $output .= "\n".'</ul><div class="cl_both"></div><ul class="extra">'; $caunt_ul ++; $caunt = 0; } $caunt ++; } if ($level == 0) { $wrapper_level1 =''; $wrapper_level2 =''; } $output .= '<li class="current_'.$level.'"><a href="'; if (!$level) { unset($GLOBALS['cPath_set']); $GLOBALS['cPath_set'][0] = $key; $cPath_new = 'cPath=' . $key; } else { $GLOBALS['cPath_set'][$level] = $key; $cPath_new = 'cPath=' . implode("_", array_slice($GLOBALS['cPath_set'], 0, ($level+1))); } if (tep_has_category_subcategories($key) && $classname_for_parent) { $this_parent_class = ' class="'.$classname_for_parent.'"'; } else { $this_parent_class = ''; } $categories_name = ((strlen($val['name']) > MAX_DESCR_CATEGORY_NAME) ? substr($val['name'], 0, MAX_DESCR_CATEGORY_NAME) . '...' : $val['name']); $categories_desc = ((strlen($val['descr']) > MAX_DESCR_CATEGORY_DESCRIPTION && MAX_DESCR_CATEGORY_DESCRIPTION != 0) ? ((strlen($val['descr']) > MAX_DESCR_CATEGORY_DESCRIPTION) ? substr($val['descr'], 0, MAX_DESCR_CATEGORY_DESCRIPTION) . '...' : $val['descr']) : ''); if (SUPERFISH_CUSTOM_BOX == 'Picture and Description of Categories') { if ($val['image'] != '') { $data_rel = 'data-rel="'.DIR_WS_IMAGES . $val['image'].'"'; }else{ $data_rel = 'data-rel=""'; } $data_desc = 'data-desc="'.$categories_desc.'"'; $output .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '"'.$this_parent_class.' '.$data_rel.' '.$data_desc.' >'.$categories_name.''; }else if (SUPERFISH_CUSTOM_BOX == 'Custom HTML Box') { $output .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '"'.$this_parent_class.'>'.$categories_name.''; }else{ $output .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '"'.$this_parent_class.'>'.$categories_name.''; } if (SUPERFISH_MODUL_COUNTS == 'Show') { $products_in_category = tep_count_products_in_category($key); if ($products_in_category > 0) { if ($GLOBALS['this_level'] > 0) { $output .= ' (' . $products_in_category . ')'; }else{ $output .= ''; } } } if ($this_parent_class != '') { $output .= ''.$wrapper_level2.'</a>'; }else{ $output .= ''.$wrapper_level2.'</a>'; } if (!tep_has_category_subcategories($key)) { $output .= '</li>'."\n"; } if ((isset($table[$key])) AND (($maxlevel > $level + 1) OR ($maxlevel == '0'))) { // if($GLOBALS['this_level']<=1) $output .= tep_make_catsf_ulbranch($key,$table,$level + 1,$maxlevel); } } // End while loop return $output;} ?> cat_navbar.php Link to comment Share on other sites More sharing options...
♥bruyndoncx Posted August 18, 2015 Share Posted August 18, 2015 now, that is really confusing. Perhaps you can show in an example what you want to achieve as output ? my gut reaction is, put the damn thing to true ? KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt Link to comment Share on other sites More sharing options...
dfcdev Posted August 18, 2015 Author Share Posted August 18, 2015 thanks for the quick reply and my sincere apologies for not being clear so: 1. if I set the parameter "$show_full_tree" to "true" on the file that I have mentioned above, the drop down menu displays as the file attached that i labeled "show_full_tree-true.jpg" as you notice you can hover over any of the parent categories "New Arrivals, Top Sellers, Products, etc." and still get the dropdown menus regardless of whatever page you navigate to. 2. Now if I set the parameter "$show_full_tree" to "false" (and I am doing this because the subcategories on this project are far too deep and I only need to display ONE subcategory per parent category "New Arrivals, Top Sellers, Products, etc." and NOT the entire tree of subcategories) I now see the dropdown menu displaying as the file attached that i labeled "show_full_tree-false.jpg" and the only way to be able to see the subcategories for the parent categories by hovering over the parent categories is to click on the parent categories themselves, for instance I was able to hover over the parent category on the image labeled "show_full_tree-false.jpg" by clicking on "Products" ONLY then did was I able to hover over "Products" to be able to see the subcategories for "Products", if I need to see the subcategories for "New Arrivals" I need to first click on "New Arrivals" so that the subcategories are visible by hovering over "New Arrivals" so basically, I need for all of the Parent categories "New Arrivals, Top Sellers, and Products" to behave exactly how they behave on the first image "show_full_tree-true.jpg" once I set the parameter "$show_full_tree" to "false" I want to be able to hover over any of the top categories on any given page at any given time and still get the drop-downs with the subcategories for each of the parent categories. I hope this clears things up a bit now and thanks again! Link to comment Share on other sites More sharing options...
Bob Terveuren Posted August 19, 2015 Share Posted August 19, 2015 Hi - I'm still a bit confused as to what you are after but have a look at line 96 in your code - that allows you to pass over 'extra' category ids (other than zero) to build in - you'd need to change the line 84 call to the function to pass these... Not sure if that's what you#re after Link to comment Share on other sites More sharing options...
Gauravs Posted August 20, 2015 Share Posted August 20, 2015 Bit confused... with the details provided.. but I think what you are looking for is to see only 1 sub-category for each parent item? If so.. you may modify the file to limit the subcategory result to fetch only 1 result from database by adding "LIMIT 1" at the end of your db query in the line below $result = tep_db_query('select c.categories_id, cd.categories_name, cd.categories_description, c.categories_image, c.parent_id from ' . TABLE_CATEGORIES . ' c, ' . TABLE_CATEGORIES_DESCRIPTION . ' cd where c.categories_id = cd.categories_id and cd.language_id="' . (int)$languages_id .'" '.$parent_query.' order by sort_order DESC, c.sort_order, LIMIT 1'); This will result in only 1 subcategory to be fetched and displayed on any given page... HTH Best Regards,Gaurav Link to comment Share on other sites More sharing options...
dfcdev Posted August 21, 2015 Author Share Posted August 21, 2015 both options worked thanks for getting back to me! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.