Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Show Category Name in Product Info Page


webmaster69

Recommended Posts

I have seached the forums for the past 2 days trying to cure this. It's turned from a 5 minute mod to 2 days and counting mod.

 

All I want to do is display the category that the product is in in the product info page.

 

For some reason the sub category that the product is in, is NOT displayed but the parent category is.

 

Here is the code I have used:

2. Open for editing catalog/product_info.php

3. Find this line:

 

$product_check = tep_db_fetch_array($product_check_query);

 

 

Add this text below:

 

// MOD - Category Name in Product_info
$categories_name_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c on p.products_id = p2c.products_id left join " . TABLE_CATEGORIES . " c on p2c.categories_id = c.categories_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

$category = tep_db_fetch_array($categories_name_query); 
// END 

4. Find these lines:

if (tep_not_null($product_info['products_model'])) {
$products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
} else {
$products_name = $product_info['products_name'];
}


Replace with these lines:

// MOD - Category Name in Product_info
if (tep_not_null($product_info['products_model'])) {
$products_name = '<span class="categoryHeading">' . $category['categories_name'] . '</span><br>' . $product_info['products_name'] . '<br><span class="smallText">' . $product_info['products_model'] . ' </span>';
} else {
$products_name = '<span class="categoryHeading">' . $category['categories_name'] . '</span><br>' . $product_info['products_name'];
}
// END

Link to comment
Share on other sites

Hi, I believe this little contrib is what you are looking for as it was only a text page to download I will just paste it here for you!

Best Wishes!

 

Page Heading Title Better

-------------------------

 

*****************************

 

This is a modification of Tommy Le's work so that manufacturer's names will show instead of "Let's See What We Have Here" when listing products by manufacturer.

 

I also removed the unnecessary c.categories_image select from the SQL query.

 

*****************************

 

Get rid of "Let's See What We Have Here" for SubCategories and "Categories" for Top-Categories. Replace them with the name of categories or Subcategories name.

 

In the /catalog/index.php, there are three <?php echo HEADING_TITLE; ?>

 

FOR CATEGORIES, just replace the first one

<?php echo HEADING_TITLE; ?>

 

TO

 

<?php echo $category['categories_name'] ?>

 

 

FOR SUBCATEGORIES, just replace the second

<?php echo HEADING_TITLE; ?>

 

TO

 

<?php if (isset($HTTP_GET_VARS['manufacturers_id'])) {

$category_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");

$category = tep_db_fetch_array($category_query);

if ($category['manufacturers_name'] != "") {echo $category['manufacturers_name'];} else { echo HEADING_TITLE;}

} else {

$category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");

$category = tep_db_fetch_array($category_query);

if ($category['categories_name'] != "") {echo $category['categories_name'];} else { echo HEADING_TITLE;}

}

?>

 

 

The third <?php echo HEADING_TITLE; ?>

Nothing needed to modify.

Link to comment
Share on other sites

Thanks for getting back to me with this.

 

This is not what I wanted, I was wanting to display that category at the top of the product_info page.

 

Thanks for taking the time to reply, much apreciated.

 

 

Hi, I believe this little contrib is what you are looking for as it was only a text page to download I will just paste it here for you!

Best Wishes!

 

Page Heading Title Better

-------------------------

 

*****************************

 

This is a modification of Tommy Le's work so that manufacturer's names will show instead of "Let's See What We Have Here" when listing products by manufacturer.

 

I also removed the unnecessary c.categories_image select from the SQL query.

 

*****************************

 

Get rid of "Let's See What We Have Here" for SubCategories and "Categories" for Top-Categories. Replace them with the name of categories or Subcategories name.

 

In the /catalog/index.php, there are three <?php echo HEADING_TITLE; ?>

 

FOR CATEGORIES, just replace the first one

<?php echo HEADING_TITLE; ?>

 

TO

 

<?php echo $category['categories_name'] ?>

FOR SUBCATEGORIES, just replace the second

<?php echo HEADING_TITLE; ?>

 

TO

 

<?php if (isset($HTTP_GET_VARS['manufacturers_id'])) {

$category_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");

$category = tep_db_fetch_array($category_query);

if ($category['manufacturers_name'] != "") {echo $category['manufacturers_name'];} else { echo HEADING_TITLE;}

} else {

$category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");

$category = tep_db_fetch_array($category_query);

if ($category['categories_name'] != "") {echo $category['categories_name'];} else { echo HEADING_TITLE;}

}

?>

 

 

The third <?php echo HEADING_TITLE; ?>

Nothing needed to modify.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...