Answer the question
In order to leave comments, you need to log in
How to display a subcategory with pictures (Opencart)?
Good evening!
It is necessary that subcategories are displayed with pictures (those that were set in the admin panel). Here is the code of the file where you want to output the files.
OC2.0; File - product/category.tpl
<?php if ($categories) { ?>
<h3><?php echo $text_refine; ?></h3>
<?php if (count($categories) <= 5) { ?>
<section class="choose">
<article>
<?php foreach ($categories as $category) { ?>
<img src="<?echo $category['thumb']; ?>"> <!-- Вот эта переменная не находится -->
<a href="<?php echo $category['href']; ?>"><div><h2><?php echo $category['name']; ?></h2></div></a>
<?php } ?>
</article>
</section>
Answer the question
In order to leave comments, you need to log in
open catalog/controller/product/category.php and on the 180th line see how the elements of the $data['categories'][] array are set, you will declare thumb there - there will be a picture in the variable. You can see how the pictures are pulled out in the same file in the code above:
if ($category_info['image']) {
$data['thumb'] = $this->model_tool_image->resize($category_info['image'], $this->config->get('config_image_category_width'), $this->config->get('config_image_category_height'));
} else {
$data['thumb'] = '';
}
Here is perhaps another solution - here, in addition to displaying the image, there is also a breakdown of the name into the actual name and the counter of goods. It turns out something like this:
Thanks, Dmitry! Literally a few minutes before your answer, I was able to find the answer over the hill. forum.opencart.com/viewtopic.php?f=21&t=139708 If anyone needs it. Here
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question