Page 1 of 1
Put Category Pictures on Home page Instead of Latest Products
Posted: Sat Apr 12, 2008 10:13 pm
by Bijou
Hi there,
I need some instruction/coding help.
I would like to put my two product category pictures on the home page (in the place of the Latest Products pics).
I only have two categories (Classic and Chic) and want users to select one or the other, then view the products in that category.
I am thinking my home.tpl has to be modified in include the category instructions, but am not sure how.
http://www.chuneicarriers.com/shopping.html
Re: Put Category Pictures on Home page Instead of Latest Products
Posted: Sun Apr 13, 2008 7:16 pm
by bruce
You are correct. Just chop out the code displaying the latest products (shown below)
Code: Select all
<div class="heading"><?php echo $text_latest; ?></div>
<?php foreach ($products as $product) { ?>
<div class="products"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a><br /><b><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></b><br /><?php echo $product['price']; ?></div>
<?php } ?>
and put in your own html code to show the category images and info that you want.
You could also cut out the code (shown below) in catalog\controller\home.php that gets the latest products info and adds the data to the template. Just to save some unnecessary processing
Code: Select all
$product_data = array();
$results = $database->getRows("select * from product p left join product_description pd on (p.product_id = pd.product_id) left join image i on (p.image_id = i.image_id) where p.status = '1' and pd.language_id = '" . (int)$language->getId() . "' and p.date_available < now() and p.status = '1' order by p.date_added limit 6");
foreach ($results as $result) {
$product_data[] = array(
'name' => $result['name'],
'href' => $url->href('product', FALSE, array('product_id' => $result['product_id'])),
'thumb' => $image->resize($result['filename'], $config->get('config_image_width'), $config->get('config_image_height')),
// 'price' => $currency->format($tax->calculate($result['price'], $result['tax_class_id']))
'price' => $currency->format($tax->calculate($result['price'], $result['tax_class_id'], false))
);
}
$view->set('products', $product_data);
Re: Put Category Pictures on Home page Instead of Latest Products
Posted: Mon Apr 14, 2008 2:10 pm
by Bijou
Okay, did that.
I have my 'look'. But what should my <a href code look like that will bring up the product thumbs from the related category when clicked?
Bij.
Re: Put Category Pictures on Home page Instead of Latest Products
Posted: Mon Apr 14, 2008 2:23 pm
by bruce
Something like the following, where 19 is the category id in the database.
Code: Select all
<a href="http://localhost/store/index.php?controller=category&path=19">Category 1</a>