Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Adding an ALL PRODUCTS Category?


hmccorkle

Recommended Posts

How would I add an ALL PRODUCTS category? I have searched through all the documentation and have found NOTHING!

 

Immediate help will be well appreciated.

 

Thank you

Chris

 

 

well, I simply added an empty category called "all products".

I then check the category number, in my case it is 64.

 

in index.php I then do this :

 

// We show them all

if ($cPath == 64) // show all products

{$listing_sql = "select " . $select_column_list . " p.products_quantity, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and p2c.categories_id = c.categories_id and pd.language_id = '" . (int)$languages_id . "'";

}

else

{$listing_sql = "select " . $select_column_list . " p.products_quantity, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";

}

}

 

so basically I duplicate the query for showing all for a specific category and remove the category references in the where clause. That gives me all products regardless of category.

 

note: I exclude category 64 from other queries like for the tabs and the main categories though.

Treasurer MFC

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

Hello Amanda,

 

I have tried your very helpful "all products" category code suggestion above on the index.php page and also found that there were two of each product in my display results. I noticed that on your website, that only one of each item displaying in the "all products" results. Other than needing to narrow the display down to only one of each product, this suggestion is exactly what I am looking for.

 

Could you please share with us the code details to duplicate the "all products" category mod you accomplished as well as the code to exclude the "all products" category from displaying on the index.php page (I plan on providing the link to the all products page in the header)?

 

You can see the current results of your code above on my test site here: http://glass-rocks.com/test

 

Thank you in advance for your help!

 

Best regards,

 

Dick

Link to comment
Share on other sites

Hello Amanda,

 

I have tried your very helpful "all products" category code suggestion above on the index.php page and also found that there were two of each product in my display results. I noticed that on your website, that only one of each item displaying in the "all products" results. Other than needing to narrow the display down to only one of each product, this suggestion is exactly what I am looking for.

 

Could you please share with us the code details to duplicate the "all products" category mod you accomplished as well as the code to exclude the "all products" category from displaying on the index.php page (I plan on providing the link to the all products page in the header)?

 

You can see the current results of your code above on my test site here: http://glass-rocks.com/test

 

Thank you in advance for your help!

 

Best regards,

 

Dick

 

I assume that you have duplicated / linked products to multiple categories?

 

then I would use :

 

select distinct ......

Treasurer MFC

Link to comment
Share on other sites

I assume that you have duplicated / linked products to multiple categories?

 

then I would use :

 

select distinct ......

 

 

or try this query to get all products:

 

$listing_sql = "select " . $select_column_list . " pd.products_description, p.products_quantity, p.products_status, p.products_id, p.manufacturers_id, p.products_price, p.products_retail_price, p.products_tax_class_id from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'";

Treasurer MFC

Link to comment
Share on other sites

or try this query to get all products:

 

$listing_sql = "select " . $select_column_list . " pd.products_description, p.products_quantity, p.products_status, p.products_id, p.manufacturers_id, p.products_price, p.products_retail_price, p.products_tax_class_id from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'";

 

 

I forgot the exclusion stuff:

 

simply add the line:

 

and c.category_id != XX

 

where XX is that all products category number

 

to the query to get the categories.

Treasurer MFC

Link to comment
Share on other sites

or try this query to get all products:

 

$listing_sql = "select " . $select_column_list . " pd.products_description, p.products_quantity, p.products_status, p.products_id, p.manufacturers_id, p.products_price, p.products_retail_price, p.products_tax_class_id from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'";

 

Hello Amanda,

 

Thank you for your reply and very helpful information! I find that by using your suggestion it is easier to create an all products page for my application than integrating a special "all products" contribution.

 

I am not familiar enough with php and was unable to determine exactly where to put the "select distinct" code you first suggested without getting syntax errors, however, with your new code suggested above, I was indeed able to get the page to display one each of all products in all categories without duplication. I did need to remove the reference to p.products_retail_price, though, since I do not apparently have that field in the products_description table.

 

For those that would like to see the complete section of code in the index.php page in context that worked for me, please see below:

 

	} else {
// show the products in a given categorie
  if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
	$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
  } else {
// We show them all
  if ($cPath == 15) { // show all products
	$listing_sql = "select " . $select_column_list . " pd.products_description, p.products_quantity, p.products_status, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'";
  } else {
	$listing_sql = "select " . $select_column_list . " p.products_quantity, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
  }

  }
}

 

As per Amandas instructions will also need to change the cPath number I used from 15 to whatever your new category path number is.

 

Thanks again for all your help!

 

Dick

Link to comment
Share on other sites

I forgot the exclusion stuff:

 

simply add the line:

 

and c.category_id != XX

 

where XX is that all products category number

 

to the query to get the categories.

 

Hello Amanda,

 

Thank you for your reply and very helpful information!

 

Unfortunately, I am not familiar enough with php and was unable to determine exactly where to put the "and c.category_id != 15" code you first suggested without getting syntax errors or no results at all.

 

Can you please be more specific as to exactly where in context to place the code in order to exclude the "All Products" category name from displaying on the index.php page?

 

My index.php page currently looks like this:

 

<?php
/*
 $Id: index.php,v 1.1 2003/06/11 17:37:59 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

// the following cPath references come from application_top.php
 $category_depth = 'top';
 if (isset($cPath) && tep_not_null($cPath)) {
$categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
$cateqories_products = tep_db_fetch_array($categories_products_query);
if ($cateqories_products['total'] > 0) {
  $category_depth = 'products'; // display products
} else {
  $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");
  $category_parent = tep_db_fetch_array($category_parent_query);
  if ($category_parent['total'] > 0) {
	$category_depth = 'nested'; // navigate through the categories
  } else {
	$category_depth = 'products'; // category has no products, but display the 'no products' message
  }
}
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="0" cellpadding="0">
 <tr>
<!-- body_text //-->
<?php
 if ($category_depth == 'nested') {
$category_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");
$category = tep_db_fetch_array($category_query);
?>
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
<?php
if (isset($cPath) && strpos('_', $cPath)) {
// check to see if there are deeper categories within the current category
  $category_links = array_reverse($cPath_array);
  for($i=0, $n=sizeof($category_links); $i<$n; $i++) {
	$categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");
	$categories = tep_db_fetch_array($categories_query);
	if ($categories['total'] < 1) {
	  // do nothing, go through the loop
	} else {
	  $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
	  break; // we've found the deepest category the customer is in
	}
  }
} else {
  $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
}

$number_of_categories = tep_db_num_rows($categories_query);

$rows = 0;
while ($categories = tep_db_fetch_array($categories_query)) {
  $rows++;
  $cPath_new = tep_get_path($categories['categories_id']);
  $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
  echo '				<td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n";
  if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) {
	echo '			  </tr>' . "\n";
	echo '			  <tr>' . "\n";
  }
}

// needed for the new products module shown below
$new_products_category_id = $current_category_id;
?>
		  </tr>
		</table></td>
	  </tr>
	  <tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
	  </tr>
	  <tr>
		<td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>
	  </tr>
	</table></td>
  </tr>
</table></td>
<?php
 } elseif ($category_depth == 'products' || isset($HTTP_GET_VARS['manufacturers_id'])) {
// create column list
$define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
					 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
					 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
					 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
					 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
//Minimum quantity code
					 'PRODUCT_LIST_MINORDER' => PRODUCT_LIST_MINORDER,
//End: Minimum quantity code						 
					 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
					 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
					 'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

asort($define_list);

$column_list = array();
reset($define_list);
while (list($key, $value) = each($define_list)) {
  if ($value > 0) $column_list[] = $key;
}

$select_column_list = '';

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
  switch ($column_list[$i]) {
	case 'PRODUCT_LIST_MODEL':
	  $select_column_list .= 'p.products_model, ';
	  break;
	case 'PRODUCT_LIST_NAME':
	  $select_column_list .= 'pd.products_name, ';
	  break;
	case 'PRODUCT_LIST_MANUFACTURER':
	  $select_column_list .= 'm.manufacturers_name, ';
	  break;
	case 'PRODUCT_LIST_QUANTITY':
	  $select_column_list .= 'p.products_quantity, ';
	  break;
//Minimum quantity code
	case 'PRODUCT_LIST_MINORDER':
	  $select_column_list .= 'p.minorder, ';
	  break;
//End: Minimum quantity code		  
	case 'PRODUCT_LIST_IMAGE':
	  $select_column_list .= 'p.products_image, ';
	  break;
	case 'PRODUCT_LIST_WEIGHT':
	  $select_column_list .= 'p.products_weight, ';
	  break;
  }
}

// show the products of a specified manufacturer
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
  if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only a specific category
	$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
  } else {
// We show them all
	$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
  }
} else {
// show the products in a given categorie
  if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
	$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
  } else {
// We show them all
  if ($cPath == 15) { // show all products
	$listing_sql = "select " . $select_column_list . " pd.products_description, p.products_quantity, p.products_status, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'";
  } else {
	$listing_sql = "select " . $select_column_list . " p.products_quantity, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
  }

  }
}

if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
  for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
	if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
	  $HTTP_GET_VARS['sort'] = $i+1 . 'a';
	  $listing_sql .= " order by pd.products_id";
	  break;
	}
  }
} else {
  $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);
  $sort_order = substr($HTTP_GET_VARS['sort'], 1);
  $listing_sql .= ' order by ';
  switch ($column_list[$sort_col-1]) {
	case 'PRODUCT_LIST_MODEL':
	  $listing_sql .= "p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_id";
	  break;
	case 'PRODUCT_LIST_NAME':
	  $listing_sql .= "pd.products_id " . ($sort_order == 'd' ? 'desc' : '');
	  break;
	case 'PRODUCT_LIST_MANUFACTURER':
	  $listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_id";
	  break;
	case 'PRODUCT_LIST_QUANTITY':
	  $listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_id";
	  break;
//Minimum quantity code
	case 'PRODUCT_LIST_MINORDER':
	  $listing_sql .= "p.minorder " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_id";
	  break;
//End: Minimum quantity code		  
	case 'PRODUCT_LIST_IMAGE':
	  $listing_sql .= "pd.products_name";
	  break;
	case 'PRODUCT_LIST_WEIGHT':
	  $listing_sql .= "p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_id";
	  break;
	case 'PRODUCT_LIST_PRICE':
	  $listing_sql .= "final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_id";
	  break;
  }
}
?>
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">


<!--


  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
<?php
// optional Product List Filter
if (PRODUCT_LIST_FILTER > 0) {
  if (isset($HTTP_GET_VARS['manufacturers_id'])) {
	$filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' order by cd.categories_name";
  } else {
	$filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by m.manufacturers_name";
  }
  $filterlist_query = tep_db_query($filterlist_sql);
  if (tep_db_num_rows($filterlist_query) > 1) {
	echo '			<td align="center" class="main">' . tep_draw_form('filter', FILENAME_DEFAULT, 'get') . TEXT_SHOW . ' ';
	if (isset($HTTP_GET_VARS['manufacturers_id'])) {
	  echo tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);
	  $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES));
	} else {
	  echo tep_draw_hidden_field('cPath', $cPath);
	  $options = array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS));
	}
	echo tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']);
	while ($filterlist = tep_db_fetch_array($filterlist_query)) {
	  $options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']);
	}
	echo tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');
	echo '</form></td>' . "\n";
  }
}

// Get the right image for the top-right
$image = DIR_WS_IMAGES . 'table_background_list.gif';
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
  $image = tep_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
  $image = tep_db_fetch_array($image);
  $image = $image['manufacturers_image'];
} elseif ($current_category_id) {
  $image = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
  $image = tep_db_fetch_array($image);
  $image = $image['categories_image'];
}
?>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>


-->


  <tr>
	<td><?php include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?></td>
  </tr>
</table></td>
<?php
 } else { // default page
?>
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
	<td>




		  <table cellspacing=0 cellpadding=0>
		   <tr><td height=5></td></tr>
		   <tr>
			<td><a href=<?=tep_href_link('products.php')?>><img src=images/m16.gif width=258 height=115 border=0></a><a href=<?=tep_href_link('products.php')?>><img src=images/m17.gif width=258 height=115 border=0></a></td>
		  </tr>
		   <tr><td height=3></td></tr>
		   <tr><td height=8 width=516 bgcolor=#A8A8A8></td></tr>
		   <tr><td height=3></td></tr>
		  </table>









 <?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?>


		   <tr><td height=2 colspan=3></td></tr>

		   <tr><td colspan=3><img src=images/m24.gif width=130 height=69 border=0><img src=images/m25.gif width=129 height=69 border=0><img src=images/m26.gif width=128 height=69 border=0><img src=images/m27.gif width=129 height=69 border=0></td></tr>
		  </table>







	 </td>
   </tr>
</table>
</td>
<?php
 }
?>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

Perhaps part of the problem I'm having locating where to put the exclude code might have something to do with the custom template I'm using and the calling out of the category display in the custom header.php page as shown below:

 

<?php
/*
 $Id: header.php,v 1.42 2003/06/10 18:20:38 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// check if the 'install' directory exists, and warn of its existence
 if (WARN_INSTALL_EXISTENCE == 'true') {
if (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/install')) {
  $messageStack->add('header', WARNING_INSTALL_DIRECTORY_EXISTS, 'warning');
}
 }

// check if the configure.php file is writeable
 if (WARN_CONFIG_WRITEABLE == 'true') {
if ( (file_exists(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) && (is_writeable(dirname($HTTP_SERVER_VARS['SCRIPT_FILENAME']) . '/includes/configure.php')) ) {
  $messageStack->add('header', WARNING_CONFIG_FILE_WRITEABLE, 'warning');
}
 }

// check if the session folder is writeable
 if (WARN_SESSION_DIRECTORY_NOT_WRITEABLE == 'true') {
if (STORE_SESSIONS == '') {
  if (!is_dir(tep_session_save_path())) {
	$messageStack->add('header', WARNING_SESSION_DIRECTORY_NON_EXISTENT, 'warning');
  } elseif (!is_writeable(tep_session_save_path())) {
	$messageStack->add('header', WARNING_SESSION_DIRECTORY_NOT_WRITEABLE, 'warning');
  }
}
 }

// check session.auto_start is disabled
 if ( (function_exists('ini_get')) && (WARN_SESSION_AUTO_START == 'true') ) {
if (ini_get('session.auto_start') == '1') {
  $messageStack->add('header', WARNING_SESSION_AUTO_START, 'warning');
}
 }

 if ( (WARN_DOWNLOAD_DIRECTORY_NOT_READABLE == 'true') && (DOWNLOAD_ENABLED == 'true') ) {
if (!is_dir(DIR_FS_DOWNLOAD)) {
  $messageStack->add('header', WARNING_DOWNLOAD_DIRECTORY_NON_EXISTENT, 'warning');
}
 }

 if ($messageStack->size('header') > 0) {
echo $messageStack->output('header');
 }
?>

 <table cellspacing=0 cellpadding=0 width=728 align=center>
  <tr><td>
	<table cellspacing=0 cellpadding=0>
	 <tr><td><a href=<?=tep_href_link('index.php')?>><img src=images/m01.gif width=245 height=95 border=0></a></td>
		 <td width=116></td>
		 <td width=367>
		  <table cellspacing=0 cellpadding=0>
		   <tr><td height=26 colspan=2></td></tr>
		   <tr><td><a href=<?=tep_href_link('account.php')?> class=ml>Account</a>  <font color=#B3B3B3>|</font>  <a class=ml  href=<?=tep_href_link('login.php')?>>Login</a>  <font color=#B3B3B3>|</font>  <a class=ml  href=<?=tep_href_link('checkout_shipping.php')?>>Checkout</a>  <font color=#B3B3B3>|</font></td>
		   <td>	<a href=<?=tep_href_link('shopping_cart.php')?>><img src=images/m02.gif width=14 height=10 border=0 align=absmiddle></a>  <a class=ml  href=<?=tep_href_link('shopping_cart.php')?>><font color=#FF7011>Shopping Cart</font></a>  <a class=ml  href=<?=tep_href_link('shopping_cart.php')?>>(<?=$cart->count_contents()?> lbs)</a></td></tr>
		   <tr><td colspan=2 height=7 valign=bottom><img src=images/m03.gif width=367 height=1></td></tr>
		   <tr><td height=7 colspan=2></td></tr>
		   <tr><td class=ml valign=top> 
<? // LANGUAGES

 if (!isset($lng) || (isset($lng) && !is_object($lng))) {
include(DIR_WS_CLASSES . 'language.php');
$lng = new language;
 }

 $languages_string = '';
 reset($lng->catalog_languages);
 while (list($key, $value) = each($lng->catalog_languages)) {
$languages_string .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_LANGUAGES .  $value['directory'] . '/images/' . $value['image'], $value['name']) . '</a> ';
 }

 echo $languages_string;

?>	 


</td>

		   <td class=ml>Phone Us: <b>1-888-762-5452</b> Toll-Free		</td></tr>
		   <tr><td height=27 colspan=2></td></tr>
		  </table>
	 </td></tr>
	 <tr><td colspan=3 height=3 width=728 bgcolor=#A8A8A8></td></tr>
	 <tr><td colspan=3 height=1></td></tr>
	</table>
	<table cellspacing=0 cellpadding=0>
	 <tr><td width=206 height=63 class=bg>

<? // SEARCH ?>
		   <table cellspacing=0 cellpadding=0 width=166 align=center>
		   <?=tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get')?>
		   <tr><td height=19 colspan=2></td></tr>
		   <tr><td class=ps colspan=2>Product search:</td></tr>
		   <tr><td height=3 colspan=2></td></tr>




		   <tr><td><?=tep_draw_input_field('keywords', '', 'size="20" maxlength="30" class=go') . ' ' . tep_hide_session_id()?></td>
		   <td> <input type=image src=images/m04.gif width=34 height=21 border=0></td></tr>
		   <tr><td height=3 colspan=2></td></tr>
		   </form>
		  </table>
<? // END SEARCH ?>

		 </td>
		 <td width=366 height=63 class=bg>
		  <table cellspacing=0 cellpadding=0>
		   <tr><td height=17></td></tr>
		   <tr>
		  <td><img src=images/m05.gif width=2 height=29><a href=<?=tep_href_link('about_us.php')?>><img src=images/m06.gif width=86 height=29 border=0></a><a href=<?=tep_href_link('index.php?cPath=15')?>><img src=images/m07.gif width=87 height=29 border=0></a><a  href=<?=tep_href_link('specials.php')?>><img src=images/m08.gif width=94 height=29 border=0></a><a class=ml4 href=<?=tep_href_link('contact_us.php')?>><img src=images/m09.gif width=92 height=29 border=0></a><img src=images/m10.gif width=2 height=29></td>
		</tr>
		   <tr><td height=17></td></tr>
		  </table>
		 </td>
		 <td width=156 height=63 class=bg>
		  <table cellspacing=0 cellpadding=0>
		   <tr><td height=13 colspan=2></td></tr>
		   <tr><td width=19></td><td class=ps1> Currencies:</td></tr>
		   <tr><td height=3 colspan=2></td></tr>
		   <tr><td width=19></td><td>
<? // CURRENCIES

echo tep_draw_form('currencies', tep_href_link(basename($PHP_SELF), '', $request_type, false), 'get');

reset($currencies->currencies);
$currencies_array = array();
while (list($key, $value) = each($currencies->currencies)) {
  $currencies_array[] = array('id' => $key, 'text' => $value['title']);
}

$hidden_get_variables = '';
reset($HTTP_GET_VARS);
while (list($key, $value) = each($HTTP_GET_VARS)) {
  if ( ($key != 'currency') && ($key != tep_session_name()) && ($key != 'x') && ($key != 'y') ) {
	$hidden_get_variables .= tep_draw_hidden_field($key, $value);
  }
}

  echo tep_draw_pull_down_menu('currency', $currencies_array, $currency, 'onChange="this.form.submit(); " style="width:110px; font-size: 9px" ') . $hidden_get_variables . tep_hide_session_id();
echo '</form>';

?>			   


		   </td></tr>
		   <tr><td height=16 colspan=2></td></tr>
		  </table>
	 </td></tr>
	</table>
	<table cellspacing=0 cellpadding=0>
	 <tr><td width=207 valign=top>
		  <table cellspacing=0 cellpadding=0>
		   <tr><td width=207 height=33 class=bg1 valign=top>	   <a href=<?=tep_href_link('advanced_search.php')?> class=ml1>Advanced Search</a></td></tr>			   
		   <tr><td height=4></td></tr>
		  </table>
		  <table cellspacing=0 cellpadding=0>
		   <tr><td class=br width=207>
				<table cellspacing=0 cellpadding=0>
				 <tr><td background=images/m13.gif width=205 height=33 class=ps>	  Product Categories</td></tr>
				</table>
				<table cellspacing=0 cellpadding=0 width=163 align=center>
				 <tr><td height=15></td></tr>

<?   // ---- CATEGORIES

 function tep_show_category($counter) {
global $tree, $categories_string, $cPath_array;

  if(!$tree[$counter]['level']){			   

$categories_string .= $categories_string ? '<tr><td><img src=images/m14.gif width=163 height=1></td></tr><tr><td height=4></td></tr>' : '';			 

$categories_string .= '<tr><td>  <a class=ml2 href=';

if ($tree[$counter]['parent'] == 0) {
  $cPath_new = 'cPath=' . $counter;
} else {
  $cPath_new = 'cPath=' . $tree[$counter]['path'];
}
$categories_string .= tep_href_link('index.php', $cPath_new) . '>';
// display categry name
$categories_string .= $tree[$counter]['name'];
$categories_string .= '</a></td></tr><tr><td height=4></td></tr>';

  }else{  // SUBCATEGORY

$categories_string .= '<tr><td>	';

for($i=0;$i<$tree[$counter]['le vel'];$i++)
 $categories_string .= '   ';

$categories_string .= ' - <a style="font-weight:normal;" href=';   
if ($tree[$counter]['parent'] == 0) {
  $cPath_new = 'cPath=' . $counter;
} else {
  $cPath_new = 'cPath=' . $tree[$counter]['path'];
}
$categories_string .= tep_href_link('index.php', $cPath_new) . '>';
// display category name
$categories_string .= $tree[$counter]['name'];
$categories_string .= '</a></td></tr><tr><td height=4></td></tr>';
  }  

if ($tree[$counter]['next_id'] != false) {
  tep_show_category($tree[$counter]['next_id']);
}  
 }



 define(TABLE_CATEGORIES, "categories");
 define(TABLE_CATEGORIES_DESCRIPTION, "categories_description");
 $categories_string = '';
 $tree = array();

 $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 = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
 while ($categories = tep_db_fetch_array($categories_query))  {
$tree[$categories['categories_id']] = array('name' => $categories['categories_name'],
											'parent' => $categories['parent_id'],
											'level' => 0,
											'path' => $categories['categories_id'],
											'next_id' => false);

if (isset($parent_id)) {
  $tree[$parent_id]['next_id'] = $categories['categories_id'];
}

$parent_id = $categories['categories_id'];

if (!isset($first_element)) {
  $first_element = $categories['categories_id'];
}
 }

 //------------------------
 if ($cPath) {
$new_path = '';
reset($cPath_array);
while (list($key, $value) = each($cPath_array)) {
  unset($parent_id);
  unset($first_id);
  $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 = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
  if (tep_db_num_rows($categories_query)) {
	$new_path .= $value;
	while ($row = tep_db_fetch_array($categories_query)) {
	  $tree[$row['categories_id']] = array('name' => $row['categories_name'],
										   'parent' => $row['parent_id'],
										   'level' => $key+1,
										   'path' => $new_path . '_' . $row['categories_id'],
										   'next_id' => false);

	  if (isset($parent_id)) {
		$tree[$parent_id]['next_id'] = $row['categories_id'];
	  }

	  $parent_id = $row['categories_id'];

	  if (!isset($first_id)) {
		$first_id = $row['categories_id'];
	  }

	  $last_id = $row['categories_id'];
	}
	$tree[$last_id]['next_id'] = $tree[$value]['next_id'];
	$tree[$value]['next_id'] = $first_id;
	$new_path .= '_';
  } else {
	break;
  }
}
 }
 $categories_string .=  '';
 tep_show_category($first_element); 
 $categories_string .=  '';

 echo $categories_string;
?>


				 <tr><td height=14></td></tr>
				</table>
		   </td></tr>
		  </table>
		  <table cellspacing=0 cellpadding=0>
		   <tr><td height=2></td></tr>
		   <tr><td class=br width=207>
				<table cellspacing=0 cellpadding=0>
				 <tr><td background=images/m35.gif width=205 height=33 class=ps>	  Information</td></tr>
				</table>
				<table cellspacing=0 cellpadding=0 width=163 align=center>
				 <tr><td height=15></td></tr>
				 <tr><td class="m12">  <a style="font-weight:normal;" a href=<?=tep_href_link('color_chart.php')?>>Color Chart</a></a></td></tr><tr><td height=4></td></tr>
				 <tr><td><img src=images/m14.gif width=163 height=1></td></tr><tr><td height=4></td></tr>
				 <tr><td class="m12">  <a style="font-weight:normal;" a href=<?=tep_href_link('photos.php')?>>Photos</a></a></td></tr><tr><td height=4></td></tr>
				 <tr><td><img src=images/m14.gif width=163 height=1></td></tr><tr><td height=4></td></tr>					 					 					 
				 <tr><td class="m12">  <a style="font-weight:normal;" a href=<?=tep_href_link('about_us.php')?>>About Us</a></a></td></tr><tr><td height=4></td></tr>
				 <tr><td><img src=images/m14.gif width=163 height=1></td></tr><tr><td height=4></td></tr>					 
				 <tr><td class="m12">  <a style="font-weight:normal;" a href=<?=tep_href_link('products.php')?>>Products</a></a></td></tr><tr><td height=4></td></tr>
				 <tr><td><img src=images/m14.gif width=163 height=1></td></tr><tr><td height=4></td></tr>					 
				 <tr><td class="m12">  <a class=ml2 style="font-weight:normal;" a href=<?=tep_href_link('orders.php')?>>Orders</a></a></td></tr><tr><td height=4></td></tr>
				 <tr><td><img src=images/m14.gif width=163 height=1></td></tr><tr><td height=4></td></tr>
				 <tr><td class="m12">  <a style="font-weight:normal;" a href=<?=tep_href_link('shipping.php')?>>Shipping</a></a></td></tr><tr><td height=4></td></tr>
				 <tr><td><img src=images/m14.gif width=163 height=1></td></tr><tr><td height=4></td></tr>					 
				 <tr><td class="m12">  <a style="font-weight:normal;" a href=<?=tep_href_link('contact_us.php')?>>Contacts</a></a></td></tr><tr><td height=4></td></tr>
				 <tr><td><img src=images/m14.gif width=163 height=1></td></tr><tr><td height=4></td></tr>
				 <tr><td class="m12">  <a style="font-weight:normal;" a href=<?=tep_href_link('dynamic_sitemap.php')?>>Site Map</a></a></td></tr><tr><td></td></tr>					
				 <tr><td height=17 colspan=2></td></tr>
				</table>
		   </td></tr>
		  </table>			  
		  <table cellspacing=0 cellpadding=0>
		   <tr><td height=2></td></tr>
		   <tr><td class=br width=207>
				<table cellspacing=0 cellpadding=0>
				 <tr>
			  <td background=images/m35.gif width=205 height=33 class=ps> 
					 Don't buy? Tell us why!</td>
			</tr>
				</table>
				<table cellspacing=0 cellpadding=0 width=165 align=center> 
				 <tr><td height=10 colspan=2></td></tr>
				 <tr><td><input type=text class=go></td><td>  <a href=<?=tep_href_link('tell_us_why.php')?>><img src=images/m36.gif width=34 height=22 border=0></a></td></tr>
				 <tr><td height=15 colspan=2></td></tr>
				</table>
		   </td></tr>
		  </table>
		 </td>
		 <td width=516 valign=top class=b01>

 

Thank you in advance for all your help!

 

Dick

Link to comment
Share on other sites

Just a thought, but you would be better adviced to install the All Products with Images contribution. Listing your products all on one page can cause problems with the search engines not to mention cause a slow loading page, assuming you have a large number of producs.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Just a thought, but you would be better adviced to install the All Products with Images contribution. Listing your products all on one page can cause problems with the search engines not to mention cause a slow loading page, assuming you have a large number of producs.

 

Jack

 

Hi Jack,

 

I appreciate the feedback.

 

I have Amanda's code working to parcel out just 6 products on a page at a time with a Next link at the bottom of the page, which is consistent with the format of the rest of my website. I tried the All Products with Images contribution, but I did not prefer the inconsistent layout.

 

Thank you for your opinion, however.

 

Have a great day!

 

Dick

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...