1
votes

all! I downloaded my template and pasted code in file - /catalog/controller/common/header.php

// Level 1
        $this->load->model('tool/image');
        $image = empty($category['image']) ? 'no_image.jpg' : $category['image'];
        $thumb = $this->model_tool_image->resize($image, 100, 100);

        $this->data['categories'][] = array(
            'name'     => $category['name'],
            'children' => $children_data,
            'column'   => $category['column'] ? $category['column'] : 1,
            'thumb'    => $thumb,
            'href'     => $this->url->link('product/category', 'path=' . $category['category_id'])
        );

then pasted in /catalog/view/theme/freetemplate/template/common/header.tpl - this code

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

images - not show -

Notice: Undefined variable: thumb ...

If I use default template - images in category menu - display. Where I made a mistake?

2
Which version of Opencart? Where do you have pasted the codes? and what is full error?DigitCart
Version 2.0.1.1, code pasted header.php and header.tpl mytemplateMaxim
<b>Notice</b>: Undefined index: thumb in <b>D:\www\freezepoint.juka.ua\catalog\view\theme\theme574\template\common\header.tpl</b>Maxim

2 Answers

0
votes

I tested your code with opencart 1 and its default theme, it worked.

As you are using opencart 2 you must change $this->data to $data:

$data['categories'][] = array(

Now it works for me on opencart 2.

0
votes

Solved! Also necessary declare variables in file - /system/modification/catalog/controller/common/header.php and everything works!