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


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


User avatar
Active Member

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by masoudqasemoc » Fri Jun 26, 2020 5:57 pm

Dear Arthur

I want to do the same "show all Parent Categories photo on main home page"
but unfortunately, i know much little coding, can you explain to me how to do it? in the photo, please.

thanks for reading this.

Newbie

Posts

Joined
Mon Jun 01, 2020 7:53 pm
Who is online

Users browsing this forum: No registered users and 79 guests