Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

changing the way categories display


Aenarion

Recommended Posts

I got some categories in my shop :

 

Computing

-Hardware

-Networks

-Cases

-etc

Games

Books

.

.

 

I m trying to change the code in categories.php so that it shows only the subcategories and not the main categories. For example.

 

Some one clicks on Computing (from another menu) the user on the left side I want him to be able to see only the categories inside Computing (hardware, networks,cases etc), nothing else.

 

Any ideas how to do this?

 

cheers

Link to comment
Share on other sites

I got some categories in my shop :

Computing

-Hardware

-Networks

 

 

Well done!!

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

are you talking about the infobox or the display in index.php

 

Is this needed always, or only when there are subcategories?

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

I m talking about the way the array $categories_string is created.

 

The content of the infobox categories.

 

The file is /includes/boxes/categories.php

 

When there are subcategories of course, which there are always in the catalog area of the eshop. On the other pages, there would be banners.

Link to comment
Share on other sites

When there are subcategories of course, which there are always in the catalog area of the eshop. On the other pages, there would be banners.

 

 

Ok, thats what I was asking 'there are always subcategories' , otherwise it gets more complex.

 

A simple change to the query should do it:

 

Find:

 

$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");

 

Replace with:

 

$catset=tep_not_null($cPath);

$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' " . ($catset ? ' and c.categories_id = ' . (int)$cPath : '' ) . " and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

 

 

;)

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

thanks a lot for the code it works like a charm.

 

I m looking for 2 more things,

 

1. how to put the category title on the heading of the infobox instead of the standard value BOX_HEADING_CATEGORIES.

2. and how to get rid the annoying arrows next to the categoris (ex. Computing ->), also to customize the way the categories are listed do i have to change the infobox code or add code in the array? I just want to add a single dotted line in between the list. the rest i can do them from the css

 

cheers again mate

Link to comment
Share on other sites

ok I managed to get rid of the annoying ->

 

One more thing I dont need the main category to be listed at all. Just the subcategories. It still shows the main category. The main category like I mentioned above i just want it to be as the header of the infobox.

Link to comment
Share on other sites

For heading title:

 

Find:

 

 

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

 new infoBoxHeading($info_box_contents, true, false);

 $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))  {

replace with:

 

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

 $categories_string = '';
 $tree = array();
 $catset=tep_not_null($cPath); if(!$catset) new infoBoxHeading($info_box_contents, true, false);
 $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' " . ($catset ? ' and c.categories_id = ' . (int)$cPath : '' ) . " 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))  {
 if ($catset){ $info_box_contents[0] = array('text' => $categories['categories_name']); new infoBoxHeading($info_box_contents, true, false);}

 

For style changes etc look at: http://www.clubosc.com/how-to-make-just-1-...rent-style.html

 

;)

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

ok i ve been following that link the last half an hour and another post of yours about bold letters.

 

and I added this code :

 

$tree[$row['categories_id']] = array('name' => '<span style="border-bottom: 1px dotted #000000; width: 190px;">' . $row['categories_name'] . '</span>',

 

which adds exactly what I need some lines under subacategories.

 

The problem with this is that the cursor does not change to a hand when you hover over the links. It stays like you 're going to select text.... weird

 

And is there a way to skip the main category from listing in your code above? since i m using the main category on the heading box, there is no point to have it again in the contents again.

 

cheers for the help

Link to comment
Share on other sites

Line 41:

 

if (tep_has_category_subcategories($counter)) {  $categories_string .= '->';	}

 

delete

 

Line 48:

 

$categories_string .= ' (' . $products_in_category . ')';

Change to:

 

if (!tep_has_category_subcategories($counter)) $categories_string .= ' (' . $products_in_category . ')';

 

line 71:

 

 if ($catset){ $info_box_contents[0] = array('text' => $categories['categories_name']); new infoBoxHeading($info_box_contents, true, false);}
  $tree[$categories['categories_id']] = array('name' => $categories['categories_name'],
											'parent' => $categories['parent_id'],
											'level' => 0,
											'path' => $categories['categories_id'],
											'next_id' => false);

change to:

 

 if ($catset){ $info_box_contents[0] = array('text' => $categories['categories_name']); new infoBoxHeading($info_box_contents, true, false);}
  else {$tree[$categories['categories_id']] = array('name' => $categories['categories_name'],
											'parent' => $categories['parent_id'],
											'level' => 0,
											'path' => $categories['categories_id'],
											'next_id' => false);  }

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

Archived

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

×
×
  • Create New...