Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Category banners


Guest

Recommended Posts

I want to add an image to the top of the category instead of the category name

 

location is in this picture

 

exampleg.jpg

 

I think it is in index.php on this line

 

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

 

My problem is that it doesn't seem to change after I edit it.

 

Not to mention my (probably very wrong) idea was to add something like

<img src="images/<?php echo $category['categories_name']; ?>.jpg" /> and just drop jpgs into my images folder with the category names, but I doubt that would work, I just need to at least find the right spot and hopefully somebody can give me some input. I am using 2.3.1

 

outcome should be something like this

 

example2rv.jpg

Link to comment
Share on other sites

  • 2 weeks later...

that could work, mind, you have several places in index.php where you have the H1 category name construction ...

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

Did you have any success with this? I'm trying to do much the same, except that I would prefer to still show the category name on the left, with the image to the right.

 

I found the piece of code that displays the category name at the top of the product list. It is line 208 which reads

 

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

I checked this out by replacing $catname with 'xxxxxx' and verifying that xxxxxxx appeared at the top of the product list.

 

What I don't know is how to replace or add to that statement to make it show an image - preferably the image referenced by categories_image but I quite like your suggestion of using a jpeg with the same name as the category.

Link to comment
Share on other sites

Please see below the code I use on the index.php page to show banners in categories.

 

<!-- Banners Start Here -->

<?php if ($text['categories_id'] == '1') { include ("banner_1.jpg"); ?>

<?php }

?>

<?php if ($text['categories_id'] == '2') { include ("banner_2.jpg"); ?>

<?php }

?>

<?php if ($text['categories_id'] == '3') { include ("banner_3.jpg"); ?>

<?php }

?>

<!-- Banners Ends Here -->

 

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

 

 

I put just above the <h1> tag so that the banner appears at the very top of the page.

 

Hope this helps.

Link to comment
Share on other sites

Your post was a great help to me, thanks so much.

 

It didn't work for me as it was - categories_id was not returning a value - but it pointed me in the right direction of achieving even more than I intended.

 

I ended up showing 2 pictures at the top of the product list, with the category name centred between them. Looks great.

 

My code for the h1 tag is

 

 

<?php echo '<br><h1><center>'; ?>

 

<?php echo ' <a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . "categories/" . $current_category_id . "a.jpg", $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</a>' . "\n"; ?>

 

<?php echo '     ' . $catname . '     '; ?>

 

<?php echo ' <a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . "categories/" . $current_category_id . "b.jpg", $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '</center></a>' . "\n"; ?>

 

</h1>

You can see how it works on my development site at www.secomputers.co.uk/catalog

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...