Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to show category image when no subcategories?


Alisha

Recommended Posts

Hi all,

 

Can anyone please help me to make the category image (eg. category_gadgets.png) appear to the right of the category title (eg. Gadgets) in the header?

In my case the category images are more important than the product images so I would really like them to appear and be large.

 

I believe in older versions (v2.2?), this happened because of this code in catalog/index.php (maybe???)

 

<tr>
<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . $category['categories_image'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
</tr>

 

I was hoping to find similar code in v2.3... but I couldn't find anything like it.

 

 

Link to comment
Share on other sites

Inside the index.php file look for this code.

 

<h1><?php echo $category['categories_name']; ?></h1>

 

And just change to

 

<h1><?php echo tep_image(DIR_WS_IMAGES . $category['categories_image'], $category['categories_name'], HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></h1>

 

That should bring up the categories image. You could just take the necessary piece of code and use a bit of css coding to show tke categories images bigger and in a different position.

Link to comment
Share on other sites

Thanks for your quick response and thanks for showing more the relevant code. Arigatou.

 

I inserted the line into my (shop under construction) and into a fresh install but any idea why the image didn't display in either?

 

I would like to do the same things for the manufacturer images too.

Link to comment
Share on other sites

Try to remove the images code out of the h1 tags and remove the HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT part and let's see if the images appear.

Revert the previous code to as it was originally

<h1><?php echo $category['categories_name']; ?></h1>

 

And add this code after it

 

<div><?php echo tep_image(DIR_WS_IMAGES . $category['categories_image'], $category['categories_name']); ?></div>

Link to comment
Share on other sites

I played around with <h1><?php echo $category['categories_name']; ?></h1> and nothing changed.

I deleted the whole line and the title still appeared so I'm assuming this isn't the relevant line.

 

I played around with <h1><?php echo $catname; ?></h1> and had more luck.

Deleting this removes the tile.

Inserting the above suggestion(s) shows a little box, an unfound image.

Link to comment
Share on other sites

OK i see...let's try one last thing....

 

Revert back all what you have done so far so that we are at the same stage as it was when we started.

 

Look for this code inside the index.php (around line 196)

 $catname = HEADING_TITLE;
    if (isset($HTTP_GET_VARS['manufacturers_id']) && !empty($HTTP_GET_VARS['manufacturers_id'])) {
      $image = tep_db_query("select manufacturers_image, manufacturers_name as catname from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
      $image = tep_db_fetch_array($image);
      $catname = $image['catname'];
    } elseif ($current_category_id) {
      $image = tep_db_query("select c.categories_image, cd.categories_name as catname from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");
      $image = tep_db_fetch_array($image);
      $catname = $image['catname'];
    }

replace with this

$catname = HEADING_TITLE;
if (isset($HTTP_GET_VARS['manufacturers_id']) && !empty($HTTP_GET_VARS['manufacturers_id'])) {
$image = tep_db_query("select manufacturers_image, manufacturers_name as catname from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
$image = tep_db_fetch_array($image);
$catname = $image['catname'];
$catimg = $image['manufacturers_image'];
} elseif ($current_category_id) {
$image = tep_db_query("select c.categories_image, cd.categories_name as catname from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");
$image = tep_db_fetch_array($image);
$catname = $image['catname'];
$catimg = $image['categories_image'];
}

and then look for this code

<h1><?php echo $catname; ?></h1>

and add this below it

<?php echo tep_image(DIR_WS_IMAGES . $catimg, $catname);?>

(!) Sorry, forgot to mention if you want to show the category image "while there are" subcategories you have to keep the code part that we did above in post #2 and #4

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...