Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Categories Box Help Please !


ken0306

Recommended Posts

Posted

Hi, I was using one categories box that can hide the parent categories. But for some reason, all categories is align to the left, when people click on it, it doesn't really indicate which one is the parent categories and which one is subcategories. can someone help please.

 

 

Here is the code.

Thank you.... :(

<?php
/*
 $Id: categories_subtab.php,v 2.0 2004/11/16 02:59:49 ChBu Exp $

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

 Copyright © 2004 osCommerce

 Released under the GNU General Public License


* This file displays a row with links to sub-categories of the selected category.
* Use this file together with categories_tab.php. 

Changelog: by Infobroker Erich Paeper
[email protected]
*/

if ($cPath !='') {

function show_subcategories($counter) 
{
global $fooa, $subcategories_string, $id, $cPath_array, $HTTP_GET_VARS;

    for ($i=0; $i<$fooa[$counter]['level']; $i++) {
     $categories_string .= "  ";
   }

$subcategories_string .= '<a class="infoBoxHeading" href="';

    if ($fooa[$counter]['parent'] == 0) {
     $cPath_new = 'cPath=' . $counter;
   } else {
     $cPath_new = 'cPath=' . $fooa[$counter]['path'];
   }



   $subcategories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';

   if (isset($cPath_array) && in_array($counter, $cPath_array)) {
     $subcategories_string .= '';
   }

// display category name

if (tep_not_null($fooa[$counter]['image'])) {
   $subcategories_string .= tep_image(DIR_WS_IMAGES . $fooa[$counter]['image'], '20', '20') . ' ' . $fooa[$counter]['name'];
}else{
   $subcategories_string .= $fooa[$counter]['name'];
}
    if (isset($cPath_array) && in_array($counter, $cPath_array)) {
     $subcategories_string .= '';
   }
// display category name
//	$subcategories_string .= $fooa[$counter]['name'];

$subcategories_string .= '';

   if (SHOW_COUNTS == 'true') {
     $products_in_category = tep_count_products_in_category($counter);
     if ($products_in_category > 0) {
     //  $categories_string .= ' (' . $products_in_category . ')';
     }
   }

if (tep_not_null($fooa[$counter]['name'])) {
$subcategories_string .= '<div style=" width:100%; border-bottom: 1px dashed #999999;height:12;"></div></br>';
}


   if ($fooa[$counter]['next_id'] != false) {
     show_subcategories($fooa[$counter]['next_id']);
   }
}
?>

<!-- subcategories //-->


                 <tr>
                   <td>
<?php

 $info_box_contents = array();


 $subcategories_query = '';
 $fooa = array();

if ($cPath) {
	$subcategories_string = '';
	$new_path = '';
	$id = split('_', $cPath);
	reset($id);
	while (list($key, $value) = each($id)) {
		unset($prev_id);
		unset($first_id);
		$subcategories_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 = '" . $value . "' and c.categories_id = cd.categories_id and cd.language_id='" . $languages_id ."' order by sort_order, cd.categories_name");
		$subcategory_check = tep_db_num_rows($subcategories_query);
		if ($subcategory_check > 0) {
			$new_path .= $value;
			while ($row = tep_db_fetch_array($subcategories_query)) {
				$fooa[$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($prev_id)) {
					$fooa[$prev_id]['next_id'] = $row['categories_id'];
				}

				$prev_id = $row['categories_id'];

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

				$last_id = $row['categories_id'];
			}
			$fooa[$last_id]['next_id'] = $fooa[$value]['next_id'];
			$fooa[$value]['next_id'] = $first_id;
			$new_path .= '_';
		} else {
			break;
		}
	}
}

if ($id[0] != ''){
	show_subcategories($id[0]); 
	//echo $subcategories_string;
}else{
	echo "";
}
 $info_box_contents = array();
 $info_box_contents[] = array('text' => $subcategories_string);

 new infoBox($info_box_contents);

?></td>
</tr>
<?php
}
?>          
<!-- subcategories_eof //-->

Archived

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

×
×
  • Create New...