Добрый вечер!
ocStore 1.5.4.1
модуль новостей для 1.5.5 jотсюда: http://www.opencart.com/index.php?route=extension/extension/info&extension_id=7058 , установка прошла успешно, жалоб нет
Теперь нужно вывести новости не отдельным модулем, а в подвале сайта.
Можно ли сделать это путем копирования кода из модуля в соответствующее место в подвале, например:
<div class="column"><ul><li><a href="http://sitename/index.php?route=information/news"><h3><?php echo $heading_title; ?></a></h3></li>
<li><?php if ($news) { ?>
<div class="box-content">
<?php foreach ($news as $news_story) { ?>
<div class="box-news">
<h4><?php echo $news_story['title']; ?></h4>
<?php echo $news_story['description']; ?> <a href="<?php echo $news_story['href']; ?>"><?php echo $text_more; ?></a></p>
<div><b><?php echo $text_posted; ?></b> <?php echo $news_story['text_posted']; ?></div>
</div>
<?php } ?>
</div>
<?php } ?></li></ul>
Если да, то как при этом отредактировать файл контроллера?
Точнее, как добавить в контроллер футера этот код, чтобы всё продолжало работать? Ключевые требования - ограничение к-ва новостей в футере и ограничение по количеству знаков в кратком описании новости.
controller/module/news.php:
<?php
class ControllerModuleNews extends Controller {
private $_name = 'news';
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');
$languages = $this->model_localisation_language->getLanguages();
$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/news.css');
$this->load->model('catalog/news');
$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['news_count'] = $this->model_catalog_news->getTotalNews();
$this->data['news_limit'] = $setting['limit'];
if ($this->data['news_count'] > $this->data['news_limit']) { $this->data['showbutton'] = true; } else { $this->data['showbutton'] = false; }
$this->data['buttonlist'] = $this->language->get('buttonlist');
$this->data['newslist'] = $this->url->link('information/news');
$this->data['numchars'] = $setting['numchars'];
if (isset($this->data['numchars'])) { $chars = $this->data['numchars']; } else { $chars = 100; }
$this->data['news'] = array();
$results = $this->model_catalog_news->getNewsShorts($setting['limit']);
foreach ($results as $result) {
$this->data['news'][] = 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/news', 'news_id=' . $result['news_id']),
'text_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';
}
$this->render();}
}
?>