How can i achieve this kind of menu navigation? Help please. I'm using this theme http://themeforest.net/item/cupid-rgen- ... te/3042304 Please see the attached image. Thank you! ASAP!
Attachments
This is the menu that I want to achieve. - mega-dropdown-menu-with-jquery.jpg (75.44 KiB) Viewed 4109 times
Seems to work great here on 1.5.6.4 after a small modification. My only question now is..... Is there any way to keep the top category and the first sub expanded on the home page where there is no path and on informational pages?
BigWil
BigWil
chokoret wrote:FIGURED OUT!!!!!! LET ME CLEAN THIS UP FOR THOSE WHO NEED THIS!! :^D
THANKX A MILLION ROGER!!
1. Open catalog/controller/module/category.php to edit , and find this part2. and after , ADD thisCode: Select all
if (isset($parts[1])) { $this->data['child_id'] = $parts[1]; } else { $this->data['child_id'] = 0; }
Code: Select all
if (isset($parts[2])) { $this->data['sisters_id'] = $parts[2]; } else { $this->data['sisters_id'] = 0; }
3. Find this part(this is below $categories = $this->model_catalog_category->getCategories(0);Code: Select all
foreach ($categories as $category) { $children_data = array(); $children = $this->model_catalog_category->getCategories($category['category_id']); foreach ($children as $child) { $data = array( 'filter_category_id' => $child['category_id'], 'filter_sub_category' => true ); $product_total = $this->model_catalog_product->getTotalProducts($data); $children_data[] = array( 'category_id' => $child['category_id'], 'name' => $child['name'] . ' (' . $product_total . ')', 'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']) ); } $data = array( 'filter_category_id' => $category['category_id'], 'filter_sub_category' => true ); $product_total = $this->model_catalog_product->getTotalProducts($data); $this->data['categories'][] = array( 'category_id' => $category['category_id'], 'name' => $category['name'] . ' (' . $product_total . ')', 'children' => $children_data, 'href' => $this->url->link('product/category', 'path=' . $category['category_id']) ); }
and above if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) { )
4. and REPLACE that with this ::Code: Select all
foreach ($categories as $category) { $children_data = array(); $children = $this->model_catalog_category->getCategories($category['category_id']); foreach ($children as $child) { $sister_data = array(); $sisters = $this->model_catalog_category->getCategories($child['category_id']); if(count($sisters) > 1) { foreach ($sisters as $sisterMember) { $sister_data[] = array( 'category_id' =>$sisterMember['category_id'], 'name' => $sisterMember['name'], 'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']. '_' . $sisterMember['category_id']) ); } $children_data[] = array( 'category_id' => $child['category_id'], 'sister_id' => $sister_data, 'name' => $child['name'], 'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']) ); }else{ $children_data[] = array( 'category_id' => $child['category_id'], 'sister_id' =>'', 'name' => $child['name'], 'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']) ); } } $data = array( 'filter_category_id' => $category['category_id'], 'filter_sub_category' => true ); $product_total = $this->model_catalog_product->getTotalProducts($data); $this->data['categories'][] = array( 'category_id' => $category['category_id'], 'name' => $category['name'], 'children' => $children_data, 'sister' => $sister_data, 'href' => $this->url->link('product/category', 'path=' . $category['category_id']) ); }
5. Now save. and open cataloge/view/theme/*yourtheme*/template/module/category.tpl , FIND6. and under that, ADDCode: Select all
<?php foreach ($category['children'] as $child) { ?> <li> <?php if ($child['category_id'] == $child_id) { ?> <a href="<?php echo $child['href']; ?>" class="active"> - <?php echo $child['name']; ?></a> <?php } else { ?> <a href="<?php echo $child['href']; ?>"> - <?php echo $child['name']; ?></a> <?php } ?>
Code: Select all
<?php if($child['sister_id']){ ?> <ul> <?php foreach($child['sister_id'] as $sisters) { ?> <li> <?php if ($sisters['category_id'] == $sisters_id) { ?> <a href="<?php echo $sisters['href']; ?>" class="active"> - <?php echo $sisters['name']; ?></a> <?php } else { ?> <a href="<?php echo $sisters['href']; ?>"> - <?php echo $sisters['name']; ?></a> <?php } ?> </li> <?php } ?> </ul> <?php } ?>
7. Now save, and go open catalog/view/theme/*yourtheme/stylesheet/stylesheet.css
FIND8. and under that, ADDCode: Select all
.box-category > ul > li ul > li > a.active + ul { display: block; }
( #06bcc3 is color code, you might want to change it to the color you want)Code: Select all
.box-category > ul > li ul > li ul > li a.active { font-weight: bold; color: #06bcc3; } .box-category > ul > li ul > li ul > li a.active + ul { display: block; }
8. Now Save, and test the view! :^D !!
Cool But i have 1 problem it Active all in a same time i want it like Drop down
// Catalog/cantroller/comman/header.php
// Line No. 93
// First take a backup, Copy this code and paste
foreach ($categories as $category) {
if ($category['top']) {
// Level 2
$children_data = array();
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach ($children as $child) {
$filter_data = array(
'filter_category_id' => $child['category_id'],
'filter_sub_category' => true
);
// Level 3 Add By Akhilesh Chaurasia, Company : The Net Connect(www.thenetconnect.com)
$children_lv3 = $this->model_catalog_category->getCategories($child['category_id']);
if($children_lv3)
{
// Level 3
$children_lv3_data = array();
foreach ($children_lv3 as $child_lv3) {
$filter_data_lv3 = array(
'filter_category_id' => $child_lv3['category_id'],
'filter_sub_category' => true
);
$children_lv3_data[] = array(
'name' => $child_lv3['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data_lv3) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'] . '_' . $child_lv3['category_id'])
);
}
$children_data[] = array(
'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']),
'children_lv3' => $children_lv3_data,
'column' => $child['column'] ? $child['column'] : 1,
);
}
else
{
$children_data[] = array(
'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
);
}
}
// Level 1
$data['categories'][] = array(
'name' => $category['name'],
'children' => $children_data,
'column' => $category['column'] ? $category['column'] : 1,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
}
}
View output in array format:
Array
(
[0] => Array
(
[name] => JEWELLERY
[children] => Array
(
[0] => Array
(
[name] => EARRINGS (1)
[href] => http://localhost/opencart_org/index.php ... path=59_68
[children_lv3] => Array
(
[0] => Array
(
[name] => Studs (1)
[href] => http://localhost/opencart_org/index.php ... h=59_68_82
)
[1] => Array
(
[name] => Drops (0)
[href] => http://localhost/opencart_org/index.php ... h=59_68_83
)
[2] => Array
(
[name] => Jhukams (0)
[href] => http://localhost/opencart_org/index.php ... h=59_68_84
)
)
[column] => 1
)
[1] => Array
(
[name] => RINGS (5)
[href] => http://localhost/opencart_org/index.php ... path=59_60
[children_lv3] => Array
(
[0] => Array
(
[name] => Casual (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_61
)
[1] => Array
(
[name] => Cocktail (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_62
)
[2] => Array
(
[name] => Bands (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_63
)
[3] => Array
(
[name] => Men's Rings (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_64
)
[4] => Array
(
[name] => Engagement Rings (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_65
)
[5] => Array
(
[name] => Couple bands (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_66
)
[6] => Array
(
[name] => Bridal Set (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_67
)
)
[column] => 1
)
[2] => Array
(
[name] => PENDANTS (0)
[href] => http://localhost/opencart_org/index.php ... path=59_69
[children_lv3] => Array
(
[0] => Array
(
[name] => Casual (0)
[href] => http://localhost/opencart_org/index.php ... h=59_69_85
)
[1] => Array
(
[name] => Tanmaniya (0)
[href] => http://localhost/opencart_org/index.php ... h=59_69_86
)
)
[column] => 1
)
[3] => Array
(
[name] => CHAINS AND NECKLACES (0)
[href] => http://localhost/opencart_org/index.php ... path=59_70
[children_lv3] => Array
(
[0] => Array
(
[name] => Chain (0)
[href] => http://localhost/opencart_org/index.php ... h=59_70_87
)
[1] => Array
(
[name] => Neckles (0)
[href] => http://localhost/opencart_org/index.php ... h=59_70_88
)
)
[column] => 1
)
[4] => Array
(
[name] => BANGELS AND BRACLESTS (0)
[href] => http://localhost/opencart_org/index.php ... path=59_71
[children_lv3] => Array
(
[0] => Array
(
[name] => Single Line (0)
[href] => http://localhost/opencart_org/index.php ... h=59_71_89
)
[1] => Array
(
[name] => Board Lines (0)
[href] => http://localhost/opencart_org/index.php ... h=59_71_90
)
)
[column] => 1
)
[5] => Array
(
[name] => DIAMOND AND JEWELLERY (0)
[href] => http://localhost/opencart_org/index.php ... path=59_72
)
[6] => Array
(
[name] => GOLD JEWELLERY (0)
[href] => http://localhost/opencart_org/index.php ... path=59_73
)
[7] => Array
(
[name] => SOLITAIRE JEWELLERY (0)
[href] => http://localhost/opencart_org/index.php ... path=59_74
)
)
[column] => 4
[href] => http://localhost/opencart_org/index.php ... ry&path=59
)
[1] => Array
(
[name] => SOLITAIRES
[children] => Array
(
[0] => Array
(
[name] => Design Your Won (0)
[href] => http://localhost/opencart_org/index.php ... path=75_91
)
[1] => Array
(
[name] => Loose Diamond (0)
[href] => http://localhost/opencart_org/index.php ... path=75_92
)
[2] => Array
(
[name] => Diamond Education (0)
[href] => http://localhost/opencart_org/index.php ... path=75_93
)
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=75
)
[2] => Array
(
[name] => GOLD COINS
[children] => Array
(
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=76
)
[3] => Array
(
[name] => GIFTS
[children] => Array
(
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=77
)
[4] => Array
(
[name] => COLLECTIONS
[children] => Array
(
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=78
)
[5] => Array
(
[name] => TRY@HOME
[children] => Array
(
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=79
)
[6] => Array
(
[name] => SHIPS FAST
[children] => Array
(
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=80
)
[7] => Array
(
[name] => OFFERS
[children] => Array
(
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=81
)
)
// Line No. 93
// First take a backup, Copy this code and paste
foreach ($categories as $category) {
if ($category['top']) {
// Level 2
$children_data = array();
$children = $this->model_catalog_category->getCategories($category['category_id']);
foreach ($children as $child) {
$filter_data = array(
'filter_category_id' => $child['category_id'],
'filter_sub_category' => true
);
// Level 3 Add By Akhilesh Chaurasia, Company : The Net Connect(www.thenetconnect.com)
$children_lv3 = $this->model_catalog_category->getCategories($child['category_id']);
if($children_lv3)
{
// Level 3
$children_lv3_data = array();
foreach ($children_lv3 as $child_lv3) {
$filter_data_lv3 = array(
'filter_category_id' => $child_lv3['category_id'],
'filter_sub_category' => true
);
$children_lv3_data[] = array(
'name' => $child_lv3['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data_lv3) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'] . '_' . $child_lv3['category_id'])
);
}
$children_data[] = array(
'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']),
'children_lv3' => $children_lv3_data,
'column' => $child['column'] ? $child['column'] : 1,
);
}
else
{
$children_data[] = array(
'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
);
}
}
// Level 1
$data['categories'][] = array(
'name' => $category['name'],
'children' => $children_data,
'column' => $category['column'] ? $category['column'] : 1,
'href' => $this->url->link('product/category', 'path=' . $category['category_id'])
);
}
}
View output in array format:
Array
(
[0] => Array
(
[name] => JEWELLERY
[children] => Array
(
[0] => Array
(
[name] => EARRINGS (1)
[href] => http://localhost/opencart_org/index.php ... path=59_68
[children_lv3] => Array
(
[0] => Array
(
[name] => Studs (1)
[href] => http://localhost/opencart_org/index.php ... h=59_68_82
)
[1] => Array
(
[name] => Drops (0)
[href] => http://localhost/opencart_org/index.php ... h=59_68_83
)
[2] => Array
(
[name] => Jhukams (0)
[href] => http://localhost/opencart_org/index.php ... h=59_68_84
)
)
[column] => 1
)
[1] => Array
(
[name] => RINGS (5)
[href] => http://localhost/opencart_org/index.php ... path=59_60
[children_lv3] => Array
(
[0] => Array
(
[name] => Casual (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_61
)
[1] => Array
(
[name] => Cocktail (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_62
)
[2] => Array
(
[name] => Bands (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_63
)
[3] => Array
(
[name] => Men's Rings (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_64
)
[4] => Array
(
[name] => Engagement Rings (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_65
)
[5] => Array
(
[name] => Couple bands (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_66
)
[6] => Array
(
[name] => Bridal Set (1)
[href] => http://localhost/opencart_org/index.php ... h=59_60_67
)
)
[column] => 1
)
[2] => Array
(
[name] => PENDANTS (0)
[href] => http://localhost/opencart_org/index.php ... path=59_69
[children_lv3] => Array
(
[0] => Array
(
[name] => Casual (0)
[href] => http://localhost/opencart_org/index.php ... h=59_69_85
)
[1] => Array
(
[name] => Tanmaniya (0)
[href] => http://localhost/opencart_org/index.php ... h=59_69_86
)
)
[column] => 1
)
[3] => Array
(
[name] => CHAINS AND NECKLACES (0)
[href] => http://localhost/opencart_org/index.php ... path=59_70
[children_lv3] => Array
(
[0] => Array
(
[name] => Chain (0)
[href] => http://localhost/opencart_org/index.php ... h=59_70_87
)
[1] => Array
(
[name] => Neckles (0)
[href] => http://localhost/opencart_org/index.php ... h=59_70_88
)
)
[column] => 1
)
[4] => Array
(
[name] => BANGELS AND BRACLESTS (0)
[href] => http://localhost/opencart_org/index.php ... path=59_71
[children_lv3] => Array
(
[0] => Array
(
[name] => Single Line (0)
[href] => http://localhost/opencart_org/index.php ... h=59_71_89
)
[1] => Array
(
[name] => Board Lines (0)
[href] => http://localhost/opencart_org/index.php ... h=59_71_90
)
)
[column] => 1
)
[5] => Array
(
[name] => DIAMOND AND JEWELLERY (0)
[href] => http://localhost/opencart_org/index.php ... path=59_72
)
[6] => Array
(
[name] => GOLD JEWELLERY (0)
[href] => http://localhost/opencart_org/index.php ... path=59_73
)
[7] => Array
(
[name] => SOLITAIRE JEWELLERY (0)
[href] => http://localhost/opencart_org/index.php ... path=59_74
)
)
[column] => 4
[href] => http://localhost/opencart_org/index.php ... ry&path=59
)
[1] => Array
(
[name] => SOLITAIRES
[children] => Array
(
[0] => Array
(
[name] => Design Your Won (0)
[href] => http://localhost/opencart_org/index.php ... path=75_91
)
[1] => Array
(
[name] => Loose Diamond (0)
[href] => http://localhost/opencart_org/index.php ... path=75_92
)
[2] => Array
(
[name] => Diamond Education (0)
[href] => http://localhost/opencart_org/index.php ... path=75_93
)
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=75
)
[2] => Array
(
[name] => GOLD COINS
[children] => Array
(
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=76
)
[3] => Array
(
[name] => GIFTS
[children] => Array
(
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=77
)
[4] => Array
(
[name] => COLLECTIONS
[children] => Array
(
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=78
)
[5] => Array
(
[name] => TRY@HOME
[children] => Array
(
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=79
)
[6] => Array
(
[name] => SHIPS FAST
[children] => Array
(
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=80
)
[7] => Array
(
[name] => OFFERS
[children] => Array
(
)
[column] => 1
[href] => http://localhost/opencart_org/index.php ... ry&path=81
)
)
Who is online
Users browsing this forum: No registered users and 31 guests