Задать вопрос
Ответы пользователя по тегу OpenCart
  • Как сделать вывод картинки в меню opencart?

    @mts2050 Автор вопроса
    Картинки выводятся в категории, там это реализовано так:

    ..../category.tpl

    <div class="well red-links">
            <?php if ($thumb) { ?>
            <div class="pull-left"><img src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?>" title="<?php echo $heading_title; ?>" class="img-thumbnail" style="margin: 0 10px 5px 0" /></div>
            <?php } ?>
            <?php if ($description) { ?>
            <?php echo $description; ?>
            <?php } ?>
    				<div class="clearfix"></div>
          </div>


    ..../category.php

    ....
    $this->load->model('tool/image');
    ....
    			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'] = '';
    			}
    ...
    			foreach ($results as $result) {
    				if ($result['image']) {
    					$image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
    				} else {
    					$image = $this->model_tool_image->resize('placeholder.png', $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
    				}
    ...
    $data['products'][] = array(
    					'product_id'  => $result['product_id'],
    					'thumb'       => $image,
    					'name'        => $result['name'],
    					'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
    					'price'       => $price,
    					'special'     => $special,
    					'tax'         => $tax,
    					'minimum'     => $result['minimum'] > 0 ? $result['minimum'] : 1,
    					'rating'      => $result['rating'],
    					'href'        => $this->url->link('product/product', 'path=' . $this->request->get['path'] . '&product_id=' . $result['product_id'] . $url)
    				);

    Пробовал так вот еще:
    ..../catalog/controller/common/header.php
    После:
    $this->load->model('catalog/product');
    Добавил:
    $this->load->model('tool/image');
    После:
    foreach ($categories as $category) {
    Добавил:
    if ($category['image']) {
    $image = $this->model_tool_image->resize($category['image'], 100, 50);
    } else {
    $image = false;					
    }

    После:
    'href'     => $this->url->link('product/category', 'path=' . $category['category_id']),

    Добавил:
    'thumb' => $image
    В файле .../common/header.tpl
    Выводил так:
    <img src="<?php echo $category['thumb']; ?>" border="0">
    Ответ написан
    1 комментарий