Jump to content

Get subcategory images in raster view


Roel_tje

Recommended Posts

Hallo,

 

I'm using a Pavothems design in my Opencart webshop. The subcategory's in this theme were only visible as a button with title of the category. I wanted to change that, result has to be an image with title.

 

After a few changes to the original Category.tpl and Category.php I succeeded to get images and titles. Example: http://www.novalarm.nl/index.php?route=product/category&path=65_67

 

These changes are quite simple because I used pieces of code from subcatimagesv1.2. Download: http://www.opencart.com/index.php?route=extension/extension/info&extension_id=3907

 

Now the problem is, I would like to get the overview in a nice raster instead of a vertical line down. My knowledge about coding is to small to make the right changes. Can somebody help me get this right?

 

The code in Category.tpl and Category.php that I changed:

 

Category.tpl original:



<?php foreach ($categories as $category) { ?>
      <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></li>
      <?php } ?>


 

Changed:



<?php foreach ($categories as $category) { ?>
      <div>
<?php if ($category['thumb']) { ?>
<div class="image">
<a href="<?php echo $category['href']; ?>"><img src="<?php echo $category['thumb']; ?>" alt="<?php echo $category['name']; ?>" /></a>
</div>
<?php } ?>
<a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></div></div>
<?php } ?>


 

Category.php original:



'filter_sub_category' => true
);
 
$product_total = $this->model_catalog_product->getTotalProducts($data);
 
$this->data['categories'][] = array(
'name'  => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
);
}


 

Changed:



'filter_sub_category' => true
);
 
if ($this->config->get('config_product_count')) {
$product_total = $this->model_catalog_product->getTotalProducts($data);
$image = $this->model_tool_image->resize($result['image'], 80, 80);
$this->data['categories'][] = array(
'name'  => $result['name'] . ' (' . $product_total . ')',
'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url),
'thumb' => $image
);
} else {
$image = $this->model_tool_image->resize($result['image'], 80, 80);
$this->data['categories'][] = array(
'name'  => $result['name'],
'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url),
'thumb' => $image
);
}
}


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.