Evario Posted February 28, 2007 Share Posted February 28, 2007 i I'm trying to modify this menu to only display categories that have at least one product in stock. Any pointers on how I would go about doing this? You can view the menu as it is right now at www.dailyknife.com . Thanks in advance, Marc CODE: <? // cssMenu - Begin of configuration // $cssMenuConfig = array(); $cssMenuConfig['ShowEmptyCategories'] = false; // Should CSS Menu show empty categories? true / false; // cssMenu - End of configuration // ?> <style type="text/css"> .suckerdiv ul{ margin: 0; padding: 0; list-style-type: none; width: 178px; /* Width of Menu Items */ border-bottom: 1px solid #ccc; font-family: arial; font-size: 11px; } .suckerdiv ul li{ position: relative; background-color: #842B00; } /*1st level sub menu style */ .suckerdiv ul li ul{ left: 177px; /* Parent menu width - 1*/ position: absolute; width: 120px; /*sub menu width*/ top: 0; display: none; } /*All subsequent sub menu levels offset */ .suckerdiv ul li ul li ul{ left: 119px; /* Parent menu width - 1*/ } /*All subsequent sub menu levels offset */ .suckerdiv ul li ul li a{ left: 119px; /* Parent menu width - 1*/ background-color: #993300; } /*All subsequent sub menu levels offset */ .suckerdiv ul li ul li ul li a{ background-color: #C44000; } /*All subsequent sub menu levels offset */ .suckerdiv ul li ul li ul li ul li a{ background-color: #993300; } /* menu links style */ .suckerdiv ul li a{ display: block; color: white; text-decoration: none; background-color: #993300; padding: 1px 5px; border: 1px solid #ccc; border-bottom: 0; line-height: 2em; } .suckerdiv ul li a:visited{ color: white; } .suckerdiv ul li a:hover{ background-color: #590000; color: white; text-decoration: none; } .suckerdiv ul li ul li a:hover{ background-color: #590000; color: white; text-decoration: none; } .suckerdiv ul li ul li ul li a:hover{ background-color: #590000; color: white; text-decoration: none; } /* The main categories with sub-categories */ .suckerdiv .subfolderstyle{ background: url(images/arrow-list.gif) no-repeat center right; } /* This one colors the sub-folder with other sub-folders */ .suckerdiv ul li ul .subfolderstyle { background-color: #993300; } /* This one colors the sub-folder with other sub-folders */ .suckerdiv ul li ul li ul .subfolderstyle { background-color: #C44000; } /* This one colors the sub-folder with other sub-folders */ .suckerdiv ul li ul li ul li ul .subfolderstyle { background-color: #C44000; } /* Holly Hack for IE \*/ * html .suckerdiv ul li { float: left; height: 1%; } * html .suckerdiv ul li a { height: 1%; } /* End */ </style> <script type="text/javascript"> var menuids=["suckertree1"] //Enter id(s) of SuckerTree UL menus, separated by commas function buildsubmenus(){ for (var i=0; i<menuids.length; i++){ var ultags=document.getElementById(menuids).getElementsByTagName("ul") for (var t=0; t<ultags.length; t++){ ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle" ultags[t].parentNode.onmouseover=function(){ this.getElementsByTagName("ul")[0].style.display="block" } ultags[t].parentNode.onmouseout=function(){ this.getElementsByTagName("ul")[0].style.display="none" } } } } if (window.addEventListener) window.addEventListener("load", buildsubmenus, false) else if (window.attachEvent) window.attachEvent("onload", buildsubmenus) </script> <? function PrintSubMenus( $parentID, $languageID, $start_path ){ global $cssMenuConfig; $returnval = ''; if (($start_path == '') && ($parentID > 0)) { $start_path = $parentID; } else { if ($parentID > 0) $start_path .= "_" . $parentID; } if ($parentID != 0) { $returnval .= "<ul>"; } else { $returnval .= "<div class='suckerdiv'>"; $returnval .= "<ul id='suckertree1'>"; } $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '".$parentID."' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languageID ."' order by sort_order, cd.categories_name"); while ($categories = tep_db_fetch_array($categories_query)) { if ($start_path == "") { $grouppath = $categories['categories_id']; } else { $grouppath = $start_path . "_" . $categories['categories_id']; } $cPath_new = 'cPath=' . $grouppath; $categories_string = tep_href_link(FILENAME_DEFAULT, $cPath_new); $totalitemsincategory = tep_count_products_in_category($categories['categories_id']); if (cssMenu_ShowCategory($cssMenuConfig['ShowEmptyCategories'], $totalitemsincategory)) { $returnval .= "<li><a href='".$categories_string."'>".$categories['categories_name']."</a>"; } if ( tep_has_category_subcategories($categories['categories_id'] ) ) { $returnval .= PrintSubMenus( $categories['categories_id'], $languageID, $start_path ); } if (cssMenu_ShowCategory($cssMenuConfig['ShowEmptyCategories'], $totalitemsincategory)) { $returnval .= "</li>"; } } $returnval .= "</ul>"; if ($parentID == 0) $returnval .= "</div>"; return $returnval; } function cssMenu_ShowCategory( $switch, $products) { if ( $switch == 1 ) { return true; } else { if ($products > 0) { return true; } else { return false; } } } ?> <tr> <td align="center"> <img src="templates/Original/images/infobox/whichknife.gif" /> </td> </tr> <!-- categories //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => 'Which Knife?'); //new infoBoxHeading($info_box_contents, false, false); $info_box_contents = array(); $info_box_contents[] = array('text' => PrintSubMenus( 0, $languages_id, '' )); new infoBox($info_box_contents); ?> </td> </tr> <!-- End Categories --> Link to comment Share on other sites More sharing options...
Guest Posted March 1, 2007 Share Posted March 1, 2007 there is function called tep_count_products_in_category. You could use it before you display a category. If it returns 0 you do not display it. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.