Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Subcategory in another subcategory


Hajö

Recommended Posts

Hallo,

 

in my shop i have a subcategorie in a subcategorie an it looks like:

 

> category

- subcategory

- subcategory in subcategry

 

and i want to display it like this

> category

- subcategory

-- subcategory in subcategry

 

But it isn't possible to make a thrid style like class="bg_list_sub2" which is used there, because of my categories.php an i don't know how to make the changes there... :(

 

Can you help me to change the style to use first, secound and third level of categories?

 

Here is the css i want to use:

.box_body ul .bg_list a { color:#696962; background:url(images/bg_list_marker.gif) no-repeat 0 4px; padding-left:19px; line-height:22px;}
.box_body ul .bg_list a:hover { color:#939389; text-decoration:none;}
.box_body ul .bg_list_sub a{ color:#696962; line-height:18px; text-decoration:none; padding-left:19px;}
.box_body ul .bg_list_sub a:hover { color:#939389;}
.box_body ul .bg_list_sub2 a{ color:#696962; line-height:18px; text-decoration:none; padding-left:25px;}
.box_body ul .bg_list_sub2 a:hover { color:#939389;}

 

and here is the code of my categories.php:

<?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

*/
 function tep_show_category($counter, $count) {

   global $tree, $categories_string, $cPath_array, $ii;

if ($count == 0 ) $kk=' class="bg_list"'; else $kk=' class="bg_list"'; 

$count++;

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

$categories_string .= $categories_string ? '' : ''; 
$categories_string .= '<li'.$kk.'><a href=';

if (SHOW_COUNTS == 'true') {

  $products_in_category = tep_count_products_in_category($counter);
  if ($products_in_category > 0) {
	$num_prod =  ' ('.$products_in_category.')';
  }
}

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 .= $num_prod.'</a></li>';

  }else{

  	 // SUBCATEGORY

if (SHOW_COUNTS == 'true') {

  $products_in_category = tep_count_products_in_category($counter);
  if ($products_in_category > 0) {
	$num_prod =  ' ('.$products_in_category.')';
  }
}	 

$count = 2;

$categories_string .= '';	
$categories_string .= '<li class="bg_list_sub">';  

for($i=0;$i<$tree[$counter]['level'];$i++)

 $categories_string .= '';
$categories_string .= '<a 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 .= $num_prod.'</a></li>';

 }

  	if ($tree[$counter]['next_id'] != false && $ii < 30) {
  tep_show_category($tree[$counter]['next_id'], $count);

}  
 }
?>

<!-- categories //-->
	  <tr>
	<td>
<?php

 $info_box_contents = array();
 $info_box_contents[] = array('text' => BOX_HEADING_CATEGORIES);

 new infoBoxHeading($info_box_contents, true, false);

 $categories_string = '<ul>';
 $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 (tep_not_null($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;
  }
}
 }

 $count = 0;

 tep_show_category($first_element, $count); 
 $categories_string .='</ul>';
 $info_box_contents = array();
 $info_box_contents[] = array('text' => $categories_string);

 new infoBox($info_box_contents);
?>

		</td>
	  </tr>
<!-- categories_eof //-->

 

I want to use the css of .box_body ul .bg_list_sub2 on my subsubcategory. Actually the css .box_body ul .bg_list_sub is used to the subsubcategory like subcategory.

 

Sorry for my bad english, but i hope it is possible to understand... ;)

 

Greets

Hajö :)

Link to comment
Share on other sites

Sorry for writing again, but i need fast help....

 

Can anybody help me please. I tryed days but without result... :(

 

Greets

Hajö :)

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...
How did you solve it?

I have the same problem and I'm getting crazy with this!

 

Try this contrib

http://addons.oscommerce.com/info/62

 

It's easy to install.

Edit the the all_categories.php from that package.

Find $piclayout = 0;

and set to other value then 0.

 

If you want to show empty categories,

find $showempty = 0

and set to $showempty = 1

 

If you don't want opened Maincategorie + subcategorie

find $stoplevel = 1;

and set to $stoplevel = 0; //just the Maincategories will be opened than.

 

Upload the files and make a small change in column_left.php

 

FIND

include(DIR_WS_BOXES . 'categories.php');

 

Replace with

include(DIR_WS_BOXES . 'all_categories.php');

 

If you don't like the contrib undo the change in column_left.php.

 

That's it.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...