Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to display subcategories only


Guest

Recommended Posts

Anyone know of a contribution for this? I couldnt find one.. I basically need to display the subcategories wherever I want to around my shop, as a list of links.

 

Thanks for any help.

Link to comment
Share on other sites

Yeah, I just need to list the subcategories for each category on its own page. I have main links on the left which link to category 'oversiew' pages which I want to contain a list of the subcategories/ products.

 

Thanks for any help with this

Link to comment
Share on other sites

  • 4 months later...

Anyone know how to only display subcategory only (Sorry for digging up an old thread)?

 

Example:

 

index.php displays

* Apple

* Orange

* Pineapple

* Watermelon

 

and when you click into apple, it displays subcategories and no more top level categories.

 

* Apple

- New Zealand

- California

 

 

What I got so far in includes/boxes/categories.php,

 

function tep_show_category2($counter) {

global $foo, $categories_string2, $id;

 

for ($a=0; $a<$foo[$counter]['level']; $a++) {

$categories_string2 .= '<li><a href="';

$cPath_new = 'cPath=' . $foo[$counter]['path'];

$categories_string2 .= tep_href_link(FILENAME_DEFAULT, $cPath_new);

$categories_string2 .= '">';

$categories_string2 .= $foo[$counter]['name'];

$categories_string2 .= '</a></li> '."\n";

}

 

if ( ($id) && (in_array($counter, $id)) ) {

$categories_string2 .= '<li><a href="';

$cPath_new = 'cPath=' . $counter;

$categories_string2 .= tep_href_link(FILENAME_DEFAULT, $cPath_new);

$categories_string2 .= '">';

$categories_string2 .= '<b>';

$categories_string2 .= $foo[$counter]['name']. " Servers";

$categories_string2 .= '</b>';

$categories_string2 .= '</a></li> '."\n";

}

 

if ($foo[$counter]['parent'] == 0 && (sizeof($id) == 0 || !(in_array($counter, $id)) )) {

 

$categories_string2 .= '<li><a href="';

$cPath_new = 'cPath=' . $counter;

$categories_string2 .= tep_href_link(FILENAME_DEFAULT, $cPath_new);

$categories_string2 .= '">';

$categories_string2 .= $foo[$counter]['name'];

$categories_string2 .= '</a></li> '."\n";

}

Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...

<?php

 

if ($cPath && ereg('_', $cPath)) {

// check to see if there are deeper categories within the current category

$category_links = array_reverse($cPath_array);

for($i=0; $i<sizeof($category_links); $i++) {

$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 = '" . $category_links[$i] . "'

and c.categories_id = cd.categories_id

and cd.language_id = '" . $languages_id . "'

order by sort_order, cd.categories_name");

 

if (tep_db_num_rows($categories_query) < 1) {

// do nothing, go through the loop

} else {

break; // we've found the deepest category the customer is in

}

}

// replace with for not showing current category c.parent_id = '" . $current_category_id . "'

} 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 = '1'

and c.categories_id = cd.categories_id

and cd.language_id = '" . $languages_id . "'

order by sort_order, cd.categories_name");

}

 

while ($categories = tep_db_fetch_array($categories_query)) {

$cPath_new = tep_get_path($categories['categories_id']);

 

echo '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new,

'NONSSL') . '">' . $categories['categories_name'] . '</a><br>' . "\n";

}

?>

 

This is what I have found so far. However, I couldn't not figure out how to rewrite this so that the selected subcategory will have a distinctive colour. Also I want to list the parent category/subcategory of the selected subcategory and bold it. Does anyone have a clue?

 

What I want to achieve is something like the menu at ascent.co.nz

 

By the way, does anyone know an existing contribution that does dropdown subcategory menu like lmc.com.au? it works nicely with manufacturer filter.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...