Перейти к публикации
Поиск в
  • Дополнительно...
Искать результаты, содержащие...
Искать результаты в...

[Решено?..] Модуль Новости. Вывод изображения.


 Поделиться

Рекомендованные сообщения

День добрый. Столкнулся с такой проблемой - необходимо вывести изображение в модуле новости на главную, по-умолчанию вывод идёт на полный текст новости.

Вывод осуществляется в catalog/view/theme/default/template/information/news.tpl строками

<div class="image">
                    <a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" class="colorbox" rel="colorbox"><img src="<?php echo $thumb; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" id="image" /></a>
                    </div>

Мне необходимо что бы картинка выводилась на главной, т.е. этот код вставляем в catalog/view/theme/default/template/module/news. Здесь вопросов не возникает.

 

Далее необходимо определить переменную thumb в контроллере. В /catalog/controller/information/news определяется это строками

$this->data['thumb'] = $this->model_tool_image->resize($banknews_info['image'], $this->config->get('banknews_thumb_width'), $this->config->get('banknews_thumb_height'));
$this->data['popup'] = $this->model_tool_image->resize($banknews_info['image'], $this->config->get('banknews_popup_width'), $this->config->get('banknews_popup_height'));

При копировании этих строк в /catalog/controller/module/news получаем ошибку о неопределённой переменной banknews_info.
       
Подскажите как определить эту переменную? Полный код /catalog/controller/information/news ниже

 

//-----------------------------------------------------

// Dpnews Module for Opencart v1.5.6
// Modified by villagedefrance
// [email protected]
//-----------------------------------------------------

class ControllerModuleBanknews extends Controller {
private $_name = 'banknews';

protected function index($setting) {
static $module = 0;

$this->language->load('module/' . $this->_name);

$this->data['heading_title'] = $this->language->get('heading_title');

$this->load->model('localisation/language');

$this->data['customtitle'] = $this->config->get($this->_name . '_customtitle' . $this->config->get('config_language_id'));
$this->data['header'] = $this->config->get($this->_name . '_header');

if (!$this->data['customtitle']) { $this->data['customtitle'] = $this->data['heading_title']; }
if (!$this->data['header']) { $this->data['customtitle'] = ''; }

$this->data['icon'] = $this->config->get($this->_name . '_icon');
$this->data['box'] = $this->config->get($this->_name . '_box');

$this->document->addStyle('catalog/view/theme/default/stylesheet/banknews.css');

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

$this->data['text_more'] = $this->language->get('text_more');
$this->data['text_posted'] = $this->language->get('text_posted');

$this->data['show_headline'] = $this->config->get($this->_name . '_headline_module');

$this->data['banknews_count'] = $this->model_catalog_banknews->getTotalBanknews();

$this->data['banknews_limit'] = $setting['limit'];

//Thumbs
//$banknews_info = $this->model_catalog_banknews->getBanknewsStory($banknews_id);
//$this->data['banknews_info'] = $banknews_info;
//$this->load->model('catalog/banknews');
$this->data['thumb'] = $this->model_tool_image->resize($banknews_info['image'], $this->config->get('banknews_thumb_width'), $this->config->get('banknews_thumb_height'));
$this->data['popup'] = $this->model_tool_image->resize($banknews_info['image'], $this->config->get('banknews_popup_width'), $this->config->get('banknews_popup_height'));



if ($this->data['banknews_count'] > $this->data['banknews_limit']) { $this->data['showbutton'] = true; } else { $this->data['showbutton'] = false; }

$this->data['buttonlist'] = $this->language->get('buttonlist');

$this->data['banknewslist'] = $this->url->link('information/banknews');

$this->data['numchars'] = $setting['numchars'];

if (isset($this->data['numchars'])) { $chars = $this->data['numchars']; } else { $chars = 100; }

$this->data['banknews'] = array();

$results = $this->model_catalog_banknews->getBanknewsShorts($setting['limit']);

foreach ($results as $result) {
$this->data['banknews'][] = array(
'title' => $result['title'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $chars),
'href' => $this->url->link('information/banknews', 'banknews_id=' . $result['banknews_id']),
'posted' => date($this->language->get('date_format_short'), strtotime($result['date_added']))
);
}

$this->data['module'] = $module++;

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/' . $this->_name . '.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/' . $this->_name . '.tpl';
} else {
$this->template = 'default/template/module/' . $this->_name . '.tpl';
}

print_r ($banknews);

$this->render();
}


}
?>

 

Ссылка на комментарий
Поделиться на других сайтах


Не проверял...попробуйте...подозреваю надо еще .tpl поправить...

 

Код ниже

// Dpnews Module for Opencart v1.5.6
// Modified by villagedefrance
// [email protected]
//-----------------------------------------------------

class ControllerModuleBanknews extends Controller {
private $_name = 'banknews';

protected function index($setting) {
static $module = 0;

$this->language->load('module/' . $this->_name);

$this->data['heading_title'] = $this->language->get('heading_title');

$this->load->model('localisation/language');

$this->data['customtitle'] = $this->config->get($this->_name . '_customtitle' . $this->config->get('config_language_id'));
$this->data['header'] = $this->config->get($this->_name . '_header');

if (!$this->data['customtitle']) { $this->data['customtitle'] = $this->data['heading_title']; }
if (!$this->data['header']) { $this->data['customtitle'] = ''; }

$this->data['icon'] = $this->config->get($this->_name . '_icon');
$this->data['box'] = $this->config->get($this->_name . '_box');

$this->document->addStyle('catalog/view/theme/default/stylesheet/banknews.css');

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

$this->data['text_more'] = $this->language->get('text_more');
$this->data['text_posted'] = $this->language->get('text_posted');

$this->data['show_headline'] = $this->config->get($this->_name . '_headline_module');

$this->data['banknews_count'] = $this->model_catalog_banknews->getTotalBanknews();

$this->data['banknews_limit'] = $setting['limit'];

//Thumbs
//$banknews_info = $this->model_catalog_banknews->getBanknewsStory($banknews_id);
//$this->data['banknews_info'] = $banknews_info;
//$this->load->model('catalog/banknews');
//$this->data['thumb'] = $this->model_tool_image->resize($banknews_info['image'], $this->config->get('banknews_thumb_width'), $this->config->get('banknews_thumb_height'));
//$this->data['popup'] = $this->model_tool_image->resize($banknews_info['image'], $this->config->get('banknews_popup_width'), $this->config->get('banknews_popup_height'));



if ($this->data['banknews_count'] > $this->data['banknews_limit']) { $this->data['showbutton'] = true; } else { $this->data['showbutton'] = false; }

$this->data['buttonlist'] = $this->language->get('buttonlist');

$this->data['banknewslist'] = $this->url->link('information/banknews');

$this->data['numchars'] = $setting['numchars'];

if (isset($this->data['numchars'])) { $chars = $this->data['numchars']; } else { $chars = 100; }

$this->data['banknews'] = array();

$results = $this->model_catalog_banknews->getBanknewsShorts($setting['limit']);

foreach ($results as $result) {
$banknews_info = $this->model_catalog_banknews->getBanknewsStory($result['banknews_id']);
$this->data['thumb'] = $this->model_tool_image->resize($banknews_info['image'], $this->config->get('banknews_thumb_width'), $this->config->get('banknews_thumb_height'));
$this->data['popup'] = $this->model_tool_image->resize($banknews_info['image'], $this->config->get('banknews_popup_width'), $this->config->get('banknews_popup_height'));

$this->data['banknews'][] = array(
'title' => $result['title'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $chars),
'href' => $this->url->link('information/banknews', 'banknews_id=' . $result['banknews_id']),
'posted' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'thumb' => $this->data['thumb'],
'popup' => $this->data['popup']
);
}

$this->data['module'] = $module++;

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/' . $this->_name . '.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/' . $this->_name . '.tpl';
} else {
$this->template = 'default/template/module/' . $this->_name . '.tpl';
}

print_r ($banknews);

$this->render();
}


}
?>
Изменено пользователем devrvk
Ссылка на комментарий
Поделиться на других сайтах

Создайте аккаунт или войдите в него для комментирования

Вы должны быть пользователем, чтобы оставить комментарий

Создать аккаунт

Зарегистрируйтесь для получения аккаунта. Это просто!

Зарегистрировать аккаунт

Войти

Уже зарегистрированы? Войдите здесь.

Войти сейчас
 Поделиться

  • Сейчас на странице   0 пользователей

    • Нет пользователей, просматривающих эту страницу.
×
×
  • Создать...

Важная информация

На нашем сайте используются файлы cookie и происходит обработка некоторых персональных данных пользователей, чтобы улучшить пользовательский интерфейс. Чтобы узнать для чего и какие персональные данные мы обрабатываем перейдите по ссылке. Если Вы нажмете «Я даю согласие», это означает, что Вы понимаете и принимаете все условия, указанные в этом Уведомлении о Конфиденциальности.