Hi, I'm trying to create a category dropdown menu in the header using superfish in OC Ver 1.4.9.1. I followed the solution mentioned in http://forum.opencart.com/viewtopic.php?f=21&t=6651, but got a blank page with this error: Fatal error: Cannot redeclare ControllerCommonHeader::getCategories() in mypath/shop/catalog/controller/common/header.php on line 238
Please help!
Is there any chance of seeing that fragment of code where the error is appearing please maybe 5 lines before and after the error. i can't guarentee i'll fix it but i'll have a look
Site finished:
http://www.labelstogo.co.uk
Thanks dannydaman9, but I've managed to get rid of that error by deleting the private function codes in header.php. Not sure what side effects deleting those codes will have but so far everything seems fine.
Right now I'm trying to get the categories to display like they should with superfish. They're currently showing up in bullet list. I've already placed the necessary codes into header.tpl and echo category at where it should appear. Can't figure out what else I'm missing...
Right now I'm trying to get the categories to display like they should with superfish. They're currently showing up in bullet list. I've already placed the necessary codes into header.tpl and echo category at where it should appear. Can't figure out what else I'm missing...
Can you show some on the code so i can get an idea of how it is working?
Thanks
Thanks
Site finished:
http://www.labelstogo.co.uk
I removed this part from header.php:
And added <ul class="sf-menu"> into:
In header.tpl I have:
The dropdown menu shows, but only the parent categories are showing, no sub cats. I wonder if it has anything to do with the code i removed. Have been stuck the whole night...
Code: Select all
private function getCategories($parent_id, $level = 0) {
$level++;
$data = array();
$results = $this->model_catalog_category->getCategories($parent_id);
foreach ($results as $result) {
$data[] = array(
'category_id' => $result['category_id'],
'name' => str_repeat(' ', $level) . $result['name']
);
$children = $this->getCategories($result['category_id'], $level);
if ($children) {
$data = array_merge($data, $children);
}
}
return $data;
}
Code: Select all
$results = $this->model_catalog_category->getCategories($parent_id);
if ($results) {
$output .= '<ul class="sf-menu">';
Code: Select all
<div class="div5">
<div class="left"></div>
<div class="right"></div>
<div class="center">
<div class="sf-menu"><?php echo $category; ?></div>
</div>
I would believe that the code you removed uses SQL (where information is stored). To me it seems that you may have removed the code that picks up the information. i.e. catagory_id you need both parent_id and catagory_id otherwise it won't pull the information form the SQL database.
try adding this back in and find the location where you enter <ul class="sf-menu"> and place it there.
The bottom set of code seems ok i think
try adding this back in and find the location where you enter <ul class="sf-menu"> and place it there.
The bottom set of code seems ok i think
Site finished:
http://www.labelstogo.co.uk
Try this solution: css dropdown header menu
See my signature for tutorial collection on forum, may be help you in future.
See my signature for tutorial collection on forum, may be help you in future.
Who is online
Users browsing this forum: No registered users and 42 guests