Jump to content
Sign in to follow this  
Glinda

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

Recommended Posts

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

Вывод осуществляется в 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
// contact@villagedefrance.net
//-----------------------------------------------------

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();
}


}
?>

 

Share this post


Link to post
Share on other sites

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

 

Код ниже

// Dpnews Module for Opencart v1.5.6
// Modified by villagedefrance
// contact@villagedefrance.net
//-----------------------------------------------------

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();
}


}
?>
Edited by devrvk

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×

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.