Javascript opencart上的下拉菜单
我在opencart上有一个下拉边栏菜单。当我点击Javascript opencart上的下拉菜单,javascript,php,html,Javascript,Php,Html,我在opencart上有一个下拉边栏菜单。当我点击类别我想要什么时,如何使该菜单不关闭?这里是网站。www.newopt.com.ua 以下是category.phpcontroller的代码: <?php class ControllerModuleCategory extends Controller { private $categoryList; protected function index($setting) { $this->language->l
类别
我想要什么时,如何使该菜单不关闭?这里是网站。www.newopt.com.ua
以下是category.php
controller的代码:
<?php
class ControllerModuleCategory extends Controller {
private $categoryList;
protected function index($setting) {
$this->language->load('module/category');
$this->data['heading_title'] = $this->language->get('heading_title');
if (isset($this->request->get['path'])) {
$parts = explode('_', (string)$this->request->get['path']);
} else {
$parts = array();
}
if (isset($parts[0])) {
$this->data['category_id'] = $parts[0];
} else {
$this->data['category_id'] = 0;
}
if (isset($parts[1])) {
$this->data['child_id'] = $parts[1];
} else {
$this->data['child_id'] = 0;
}
if (isset($parts[2])) {
$this->data['ch3_id'] = $parts[2];
} else {
$this->data['ch3_id'] = 0;
}
$this->load->model('catalog/category');
$this->load->model('catalog/product');
$this->data['categories'] = array();
$categories = $this->model_catalog_category->getCategories(0);
$this->categoryList = $this->model_catalog_category->getCategoriesAll();
foreach ($categories as $category) {
$children_data = array();
$children = $this->childCategory($category['category_id']);
foreach ($children as $child) {
$level3 = $this->childCategory($child['category_id']);
$l3_data = array();
foreach ($level3 as $l3) {
$data = array(
'filter_category_id' => $l3['category_id'],
'filter_sub_category' => true
);
$level4 = $this->childCategory($l3['category_id']);
$l4_data = array();
foreach ($level4 as $l4) {
$data = array(
'filter_category_id' => $l4['category_id'],
'filter_sub_category' => true
);
$l4_data[] = array(
'category_id' => $l4['category_id'],
'name' => $l4['name'],
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']. '_' . $l3['category_id']. '_' . $l4['category_id'])
);
}
$l3_data[] = array(
'category_id' => $l3['category_id'],
'name' => $l3['name'],
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']. '_' . $l3['category_id']),
'children4' => $l4_data
);
}
$data1 = array(
'filter_category_id' => $child['category_id'],
'filter_sub_category' => true
);
$children_data[] = array(
'category_id' => $child['category_id'],
'name' => $child['name'],
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']),
'children3' => $l3_data
);
}
// Level 1
$data2 = array(
'filter_category_id' => $category['category_id'],
'filter_sub_category' => true
);
$this->data['categories'][] = array(
'name' => $category['name'],
'children' => $children_data,
'href' => $this->url->link('product/category', 'path=' . $category['category_id']),
'category_id' => $category['category_id']
);
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) {
$this->template = $this->config->get('config_template') . '/template/module/category.tpl';
} else {
$this->template = 'default/template/module/category.tpl';
}
$this->render();
}
protected function childCategory($cat_id) {
$child = array();
$numCategories = count($this->categoryList);
$counter = 0;
for ($i = 0; $i < $numCategories; $i++) {
if($this->categoryList[$i]['parent_id'] == $cat_id){
$child[$counter] = $this->categoryList[$i];
$counter++;
}
}
return $child;
}
}
?>
您应该显示视图(file.tpl)的代码,而不是控制器的代码。请参阅代码。请澄清:当您单击某个类别并将其转到此类别页面时,您希望在该类别突出显示的情况下保持菜单展开。是这样吗?是的。你是对的。我不知道怎么做,当我点击该类别并突出显示该类别时,下拉菜单不关闭