Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

flyout menu - how to only get it to fly out to the second subcategory


lindsayanng

Recommended Posts

I am trying to make my CSS categories flyout menu ONLY show up to the third subcategory.. This is so that I can just password protect the parent category and not have to password protect every category after it as well.. it would just be easier to not show the categories that deep on the flyout menu since custoemrs should not be able to view them anyways.

 

So here is the code for the flyout.. Any help/suggestions would be helpful~

 

<?php
/*
 $Id: categories.php,v 1.25 2003/07/09 01:13:58 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<?
// cssMenu - Begin of configuration //

$cssMenuConfig = array();
$cssMenuConfig['ShowEmptyCategories'] = true;	 // Should CSS Menu show empty categories? true / false;
$cssMenuConfig['includeProducts']	 = false;	 // Should CSSMenu show products
$cssMenuConfig['maxProductsInMenu']   = 8;		  // Maximum number of products to show in a menu ( stops massive menus being created )
$cssMenuConfig['moreText']			= "More...."; // Maximum number of products to show in a menu ( stops massive menus being created )

// cssMenu - End of configuration //
?>
<style type="text/css">

/*Credits: Dynamic Drive CSS Library */
/*URL: http://www.dynamicdrive.com/style/ */

.suckerdiv ul{
margin: 0;
padding: 0;
list-style-type: none;
width: 135px; /* Width of Menu Items */
border-bottom: 1px solid #ccc;
font-family: arial;
font-size: 11px;
}

.suckerdiv ul li{
position: relative;
background-color: #eee;
}

/*1st level sub menu style */
.suckerdiv ul li ul{
left: 134px; /* Parent menu width - 1*/
position: absolute;
width: 180px; /*sub menu width*/
top: 0;
display: none;
}

/*All subsequent sub menu levels offset */
.suckerdiv ul li ul li ul{ 
left: 180px; /* Parent menu width - 1*/
}

/*All subsequent sub menu levels offset */
.suckerdiv ul li ul li a{ 
left: 180px; /* Parent menu width - 1*/
background-color: #ddd;
}

/*All subsequent sub menu levels offset */
.suckerdiv ul li ul li ul li a{ 
background-color: #bbb;
}

/*All subsequent sub menu levels offset */
.suckerdiv ul li ul li ul li ul li a{ 
background-color: #aaa;
}

/* menu links style */
.suckerdiv ul li a{
display: block;
color: black;
text-decoration: none;
background-color: #eee;
padding: 1px 5px;
border: 1px solid #ccc;
border-bottom: 0;
line-height: 2em;
}

.suckerdiv ul li a:visited{
color: black;
}

.suckerdiv ul li a:hover{
background-color: #ffffff;
color: black;
text-decoration: none;
}

.suckerdiv ul li ul li a:hover{
background-color: #ffffff;
color: black;
text-decoration: none;
}

.suckerdiv ul li ul li ul li a:hover{
background-color: #ffffff;
color: black;
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: #ddd;
}

/* This one colors the sub-folder with other sub-folders */
.suckerdiv ul li ul li ul .subfolderstyle {
background-color: #bbb;
}

/* This one colors the sub-folder with other sub-folders */
.suckerdiv ul li ul li ul li ul .subfolderstyle {
background-color: #aaa;
}

/* 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">

//SuckerTree Vertical Menu (Aug 4th, 06)
//By Dynamic Drive: http://www.dynamicdrive.com/style/

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[i]).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 PrintProducts( $category_id, $categories_string , $includeul, $languageID)
 {
   global $cssMenuConfig;

   $product_path="product_info.php?cPath=".$category_id."&products_id=";
   $products_query = tep_db_query("select pc.products_id, pc.categories_id from products_to_categories pc, products p where pc.categories_id = " . $category_id . " and p.products_id = pc.products_id and products_status=1 order by products_price");

   $productsDisplay=mysql_num_rows( $products_query );
   $addMore= false;

   if ( $includeul  && $productsDisplay > 0 ) { 
	 $returnval .= "<ul>";

   }

   if ( $productsDisplay > $cssMenuConfig['maxProductsInMenu'] ) { 
	$productsDisplay=$cssMenuConfig['maxProductsInMenu'];
	$addMore= true;
   }

   $count_string = '';

	if (SHOW_COUNTS == 'true') {
	  if ($totalitemsincategory > 0) {
		$count_string = ' (' . $totalitemsincategory . ')';
	  }
	}

   $i=0;
   while ($i < $productsDisplay) {
	 $products = tep_db_fetch_array($products_query);
	 $product_query = tep_db_query("select products_name from products_description where products_id = " . $products['products_id'] . " AND language_id = ".$languageID );
	 $product = tep_db_fetch_array($product_query);
	 $returnval .= "<li><a href='".$product_path.$products['products_id']."'>".$product['products_name']."</a></li>\n";
	 $i++;
   }

	if ( $addMore ) {
	 $returnval .= "<li><a href='".$categories_string."'>".$cssMenuConfig['moreText']."</a></li>\n";
	}

	if ( $productsDisplay > 0 || !$includeul ) {
	$returnval .= "</ul>";
	}

	return $returnval;
 }

 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']);

	$count_string = '';

	if ((SHOW_COUNTS == 'true') && ($totalitemsincategory > 0) ){
		$count_string = ' (' . $totalitemsincategory . ')';
	}

	if (cssMenu_ShowCategory($cssMenuConfig['ShowEmptyCategories'], $totalitemsincategory)) {
		$returnval .= "<li><a href='".$categories_string."'>".$categories['categories_name'].$count_string."</a>\n";
	}
	if ( tep_has_category_subcategories($categories['categories_id'] ) ) {
	   $returnval .= PrintSubMenus( $categories['categories_id'], $languageID, $start_path );
	   if ( $cssMenuConfig['includeProducts'] ) {
		  $returnval .= PrintProducts($categories['categories_id'],$categories_string, false, $languageID);
	   }
	} else { 
	   if ( $cssMenuConfig['includeProducts'] ) {
		  $returnval .= PrintProducts($categories['categories_id'],$categories_string, true, $languageID);
	   }
	}
	if (cssMenu_ShowCategory($cssMenuConfig['ShowEmptyCategories'], $totalitemsincategory)) {
	   $returnval .= "</li>";
	}
  }
  if ( !$cssMenuConfig['includeProducts'] ) {
	$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;
	}
  }
 }
?>
<!-- categories //-->
<tr>
 <td>
<table width="100%" border="0" cellspacing="0" cellpadding="1" class="infoboxborder">
  <tr>
	<td>		  <table width=100% border=0 cellpadding=0 cellspacing=0 class="infoBoxContents">
		<tr>
		  <td colspan=3 width="100%"> <img src="images/boxes/table_categories.gif" alt="Galleries"></td>
		</tr>
		<tr>
		  <td width="100%"> 
<?php
 $info_box_contents = array();
//  $info_box_contents[] = array('text' => BOX_HEADING_CATEGORIES);

//  new infoBoxHeading($info_box_contents, true, false);

 $info_box_contents = array();
 $info_box_contents[] = array('text' => PrintSubMenus( 0, $languages_id, '' ));

 new infoBox($info_box_contents);

?>
		  </td>
		</tr>
	  </table>
	</td>
  </tr>
</table>	
 </td>
</tr>

<!-- MenuConfigategories_eof //-->

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Link to comment
Share on other sites

I've been playing around and looking throughthe contribution support thread on this issue and still can not come up with a good solution! 3 people asked the same question and no answers! anyone who comes up with the solution could probably upload a fix to the entire contribution since it is sought after

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Link to comment
Share on other sites

Seems like I might have to install a different menu mod? anyone have an suggestions for a dynamic menu that easily lets you control how deep the categories show?

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Link to comment
Share on other sites

If you look at Hide Categories & Products http://addons.oscommerce.com/info/5907

that adds an extra field to control if a category is shown, you could modify that so it controls what cats are shown in your menu.

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

But i want to show the subcategories on the index when you click on it's parent, and all the products are IN that category, i just dont want it to show on the fly out.. Does that make sense??

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...