Post by arthur » Wed Dec 13, 2017 7:07 pm

Hello,

After these changes I see my subcategories images. But..

Code: Select all

catalog/controller/product/category.php
Under this:

Code: Select all

'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url)
Added this:

Code: Select all

,'thumb' => $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_category_width'), $this->config->get($this->config->get('config_theme') . '_image_category_height'))
And small addition to category.tpl file

Code: Select all

<?php if ($category['thumb']) { ?><img src="<?php echo $category['thumb']; ?>" alt="<?php echo $category['name']; ?>" /><?php  }
Now I want to use an information page and I wish to see all first level categories here. The built-in module Category is good for that. But I don't see any images in there. I made the same changes in .tpl file (extensions/module/category.tpl). At least it says that THUMB is undefined.

What changes do I need to make in controller/extensions/module/category.php or somewhere else to see those images as well?

New member

Posts

Joined
Wed Oct 25, 2017 2:14 am

Post by DigitCart » Wed Dec 13, 2017 8:28 pm

Hi,
In catalog\controller\extension\module\category.php find:

Code: Select all

$data['categories'][] = array(
Change to:

Code: Select all

if ($category['image']) {
	$image = $this->model_tool_image->resize($category['image'], 40, 40);
} else {
	$image = $this->model_tool_image->resize('placeholder.png', 40,40);
}
$data['categories'][] = array(
	'image' => $image,
Then in catalog\view\theme\YOUR_THEME\template\extension\module\category.tpl find:

Code: Select all

<?php echo $category['name']; ?>
There are two matches.
Add before them:

Code: Select all

<img src="<?php echo $category['image']; ?>" alt="<?php echo $category['name']; ?>" title="<?php echo $category['name']; ?>" class="img-thumbnail" />

My Extensions / DigitCart


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by arthur » Wed Dec 13, 2017 9:19 pm

Thank you DigiCart. I got this error:
Fatal error: Call to a member function resize() on null in

So I had to insert this line as well and now it's all good. Thanks again 8)
$this->load->model('tool/image');

New member

Posts

Joined
Wed Oct 25, 2017 2:14 am

Post by DigitCart » Wed Dec 13, 2017 9:40 pm

Yes,
Sorry I forget to mention it.

My Extensions / DigitCart


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm

Who is online

Users browsing this forum: No registered users and 4 guests