Page 1 of 1
Error creating header dropdown menu
Posted: Wed Oct 06, 2010 6:18 pm
by knightcat
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!
Re: Error creating header dropdown menu
Posted: Wed Oct 06, 2010 11:42 pm
by dannydaman9
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
Re: Error creating header dropdown menu
Posted: Thu Oct 07, 2010 2:34 am
by knightcat
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...
Re: Error creating header dropdown menu
Posted: Thu Oct 07, 2010 4:55 pm
by dannydaman9
Can you show some on the code so i can get an idea of how it is working?
Thanks
Re: Error creating header dropdown menu
Posted: Thu Oct 07, 2010 10:34 pm
by knightcat
I removed this part from header.php:
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;
}
And added <ul class="sf-menu"> into:
Code: Select all
$results = $this->model_catalog_category->getCategories($parent_id);
if ($results) {
$output .= '<ul class="sf-menu">';
In header.tpl I have:
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>
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...

Re: Error creating header dropdown menu
Posted: Fri Oct 08, 2010 12:00 am
by dannydaman9
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
Re: Error creating header dropdown menu
Posted: Fri Oct 08, 2010 11:04 am
by qahar
Try this solution:
css dropdown header menu
See my signature for tutorial collection on forum, may be help you in future.