Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Вывод фото категории


bodyak0
 Share

Recommended Posts

Всем привет, шаблон гдефолный, сгделал вывод категорий на главной страниэто в левом блоке, не могу вывести изображения самой категории с лева, в открытот категории есть фото вывожу рядом с названием категории блок с фото {{ category.thumb }} , но ничего не выходит может есть свежее какое то решение?Просто переменную фото не могу выищить руки и знания не позволяют этого сгделать.Помогите пожалуйси

Link to comment
Share on other sites


3 хвилини назад, spectre сказав:

можете содрать с контроллера категорий им ггде подкатегорий блок

/catalog/controller/product/category.php этот?

Link to comment
Share on other sites


чет не выходит ничего, Undefined variable: image in 
фото не выводится только куча ошипотому чток

Link to comment
Share on other sites


Сгделал ик: /catalog/controller/extension/module/category.php 
 

<?php
class ControllerExtensionModuleCategory extends Controller {
    public function index() {
        $this->load->language('extension/module/category');

        $this->load->model('tool/image');
        
        if (isset($this->request->get['path'])) {
            $parts = explode('_', (string)$this->request->get['path']);
        } else {
            $parts = array();
        }

        if (isset($parts[0])) {
            $data['category_id'] = $parts[0];
        } else {
            $data['category_id'] = 0;
        }

        if (isset($parts[1])) {
            $data['child_id'] = $parts[1];
        } else {
            $data['child_id'] = 0;
        }

        $this->load->model('catalog/category');

        $this->load->model('catalog/product');

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

        $categories = $this->model_catalog_category->getCategories(0);

        foreach ($categories as $category) {
            $children_data = array();

            if ($category['category_id'] == $data['category_id']) {
                $children = $this->model_catalog_category->getCategories($category['category_id']);

                foreach($children as $child) {
                    $filter_data = array('filter_category_id' => $child['category_id'], 'filter_sub_category' => true);

                    $children_data[] = array(
                        'category_id' => $child['category_id'],
                        'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
                        'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
                    );
                }
            }

            $filter_data = array(
                'filter_category_id'  => $category['category_id'],
                'filter_sub_category' => true
            );


    if ($result['image']) {
                    $image = $this->model_tool_image->resize($result['image'], $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
                } else {
                    $image = $this->model_tool_image->resize('placeholder.png', $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_width'), $this->config->get('theme_' . $this->config->get('config_theme') . '_image_product_height'));
                }


            $data['categories'][] = array(
                'category_id' => $category['category_id'],
                'thumb'       => $image,
                'name'        => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
                'children'    => $children_data,
                'href'        => $this->url->link('product/category', 'path=' . $category['category_id'])
            );
        }

        return $this->load->view('extension/module/category', $data);
    }
}

В файле /template/extension/module/category.twig
 

  <div class="cats4 w">
    <div class="h2">Каилог</div>
    <ul>
     {% for category in categories %}
    <li>
        <div class="L">
		      <div class="image">
            <a href="{{ category.href }}"><img src="{{ category.thumb }}" alt="{{ category.name }}"/></a>
              </div>
	   </div>
        <div class="R">
            <a href="{{ child.href }}"><b>{{ category.name }}</b></a>
            {% if category.children %}
		   <ul>
			   {% for child in category.children %}
        
            <li><a href="{{ child.href }}">{{ child.name }}</a></li>
		
				 {% endfor %}
            </ul>
			    {% endif %}
        </div>
    </li>
        {% endfor %}
</ul></div>

Фото вывелось но только то что его нет как бы..
placeholder-228x228.png 
Помогите решить чтобы фото было с основной категории уже не знаю что гделать

Link to comment
Share on other sites


4 хвилини назад, spectre сказав:

а ггде вы им $result увигдели

я не силен говорю же)просто подскажите может не хваиет чего то в когде?

Link to comment
Share on other sites


3 хвилини назад, spectre сказав:

ик подсмотрите или дайте кому-то 200-300 р и вам сгделают

спасипотому что информативно

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.