Мне нужно выводить на странице производителей только первые 3 позиции. Как их можно ограничить? Сейчас они все выводятся в алфавитном порядке (по стандарту). Буду благодарен за помощь.[/size] Мне нужно на главной странице товара выводить любые 3 производителя. Я решил это сделать с помощью модуля, который сделал сам. Принцип работы модуля простой - он полностью копирует функционал страницы manufacturer_list, следовательно, он у меня на главной странице выводит всех производителей. Пример того, что сейчас получается здесь[/size]http://www.mactedesign.com/ (как видно, они идут в ряд и их очень много, а мне нужно всего 3).[/size] Код контроллера модуля manufacturers.php :
<?php class ControllerModuleManufacturers extends Controller { public function index() { $this->load->language('product/manufacturer'); $data['heading_title'] = $this->language->get('heading_title'); $data['text_brands'] = $this->language->get('text_brands'); $data['text_index'] = $this->language->get('text_index'); $data['brands'] = array(); $this->load->model('catalog/manufacturer');
$results = $this->model_catalog_manufacturer->getManufacturersByOrder(); //echo "<pre>"; print_r($setting);
$this->load->model('tool/image');
foreach ($results as $result) {
if (is_numeric(utf8_substr($result['name'], 0, 1))) {
$key = '0 - 9';
} else {
$key = utf8_substr(utf8_strtoupper($result['name']), 0, 1);
}
if (!isset($data['brands'][$key])) {
$data['brands'][$key]['name'] = $key;
}
$data['brands'][$key]['manufacturer'][] = array(
'name' => $result['name'],
'image' => $this->model_tool_image->resize($result['image'], $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height')),
'href' => $this->url->link('product/manufacturer/info', 'manufacturer_id=' . $result['manufacturer_id']),
'limit' => 3
);
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/manufacturers.tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/module/manufacturers.tpl', $data);
} else {
return $this->load->view('default/template/module/manufacturers.tpl', $data);
}
}
}
Код шаблона вывода модуля:
<h3>Top Catalogue</h3>
<div id="manu" class="owl-carouse">
<?php if ($brands) { ?>
<?php foreach ($brands as $brand) { ?>
<?php if ($brand[ 'manufacturer']) { ?>
<?php foreach ($brand[ 'manufacturer'] as $manufacturer) { ?>
<div class="item text-center">
<a href="<?php echo $manufacturer['href']; ?>"><img src="<?php echo $manufacturer['image']; ?>" class="img-responsive"></a>
<?php echo $manufacturer[ 'name']; ?>
</div>
<?php } ?>
<?php } ?>
<?php } ?>
<?php } ?>
</div>