Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Category and subcategory infoboxes


ronsts

Recommended Posts

Does anyone know of any mods or contributions that will display in the categories infobox, only the main categories in list box format. I have tried using several contributions, but it includes the categories as well as the sub categories within the list box.

 

In addition to this, is it possible to have another infobox open displaying the sub-categories when one of the top level categories is clicked in the categories infobox.

 

I have made attempts by taking this info from the default.php page, and creating an infobox with this code, but it turns out looking pretty screwy.

 

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

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

$category_links = array_reverse($cPath_array);

$size = sizeof($category_links);

for($i=0; $i<$size; $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

}

}

} 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 = '" . $current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by sort_order, cd.categories_name");

}

 

$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" style="width: ' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "n";

echo ' <td align="center" class="smallText" style="width: ' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' . '<br>' . $categories['categories_name'] . '</a></td>' . "n";

if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != tep_db_num_rows($categories_query))) {

echo ' </tr>' . "n";

echo ' <tr>' . "n";

}

}

?>

 

I am fairly new to scripting and oscommerce, but have never come across such a great customizeable ecommerce solution.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...