Здравствуйте, у меня в шаблоне есть модуль расширенных категорий (выглядит как на скриншоте). Насколько я понимаю, он написан через php и в самом файле advcategory.tpl идет ссылка на него:
<div class="box">
<div class="box-heading"><?php echo $heading_title; ?></div>
<div class="box-content">
<ul id="homemenu">
<?=$advcategory?>
</ul>
</div>
</div>
А вот сам файл advcategory.php:
<?php
/*
Code by: bequangtuyen
Y!M: laptrinhvien_ls
Home page: http://opencart.asia
Free module for opencart
*/
class ControllerModuleAdvcategory extends Controller {
protected $category_id = 0;
protected $parent_id = 0;
protected $path = array();
protected function index() {
$this->language->load('module/advcategory');
$this->data['heading_title'] = $this->language->get('heading_title');
$this->load->model('catalog/category');
$this->load->model('tool/image');
#$this->load->model('tool/seo_url');
if (isset($this->request->get['path'])) {
$this->path = explode('_', $this->request->get['path']);
$this->category_id = end($this->path);
}
$this->data['advcategory'] = $this->getCategories(0);
$this->id = 'advcategory';
$this->data['advcategory_path'] = $this->config->get('config_url') . '/catalog/view/javascript/jquery';
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/advcategory.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/advcategory.tpl';
} else {
$this->template = 'default/template/module/advcategory.tpl';
}
$this->render();
}
protected function getCategories($parent_id, $current_path = '') {
$category_id = array_shift($this->path);
$this->getParent($category_id);
$output = '';
$results = $this->model_catalog_category->getCategories($parent_id);
##if($results && $parent_id>0) $output .= '<ul>';
if($results && $parent_id>0 && $parent_id != $this->parent_id) $output .= '<ul>';
foreach ($results as $result) {
if (!$current_path) {
$new_path = $result['category_id'];
} else {
$new_path = $current_path . '_' . $result['category_id'];
}
if ($result['image']) {
$image = $result['image'];
} else {
$image = 'no_image.jpg';
}
$picture = $this->model_tool_image->resize($image, 75, 75);
$output .= '<li>';
$children = '';
$children = $this->getCategories($result['category_id'], $new_path);
if($parent_id==0) $output .= '<a href="' . $this->url->link('product/category','path=' . $new_path) . '"><img src="'.$picture.'" alt="" title="" /><b>'. $result['name'] . '</b></a>';
elseif($parent_id != $this->parent_id) $output .= '<a href="' . $this->url->link('product/category','path=' . $new_path) . '">' . $result['name'] . '</a>';
else $output .= '<a href="' . $this->url->link('product/category','path=' . $new_path) . '">В» ' . $result['name'] . '</a>';
$output .= $children;
$output .= '</li>';
}
#if($results && $parent_id>0) $output .= '</ul>';
if($results && $parent_id>0 && $parent_id != $this->parent_id) $output .= '</ul>';
return $output;
}
protected function getParent($category_id)
{
if($category_id <=0) return false;
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "category c LEFT JOIN " . DB_PREFIX . "category_description cd ON (c.category_id = cd.category_id) LEFT JOIN " . DB_PREFIX . "category_to_store c2s ON (c.category_id = c2s.category_id) WHERE c.category_id = '" . (int)$category_id . "' AND cd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int)$this->config->get('config_store_id') . "' AND c.status = '1'");
if($query->row['parent_id']==0) $this->parent_id = $category_id;
else $this->getParent($query->row['parent_id']);
В нем есть атрибуты картинок alt и title. Я хочу, чтобы они были равны названиям категорий, которым принадлежат картинки. Думаю что надо вписать что-то вроде $category['name'] , но когда я такое вписываю сайт вообще перестает открываться :-) Я бы и хотел, что бы вы мне подсказали, что надо вписать, чтобы решить поставленную задачу? И еще просто для себя хочу понять почему другие модули можно править в .tpl файлах, а этот целиком написан в php? я из-за этого очень долго не мог найти какой файл отвечает за это домашнее меню
Заранее спасибо.