Post by knightcat » Wed Oct 06, 2010 6:18 pm

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!

Newbie

Posts

Joined
Wed Oct 06, 2010 6:02 pm

Post by dannydaman9 » Wed Oct 06, 2010 11:42 pm

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:
Image
http://www.labelstogo.co.uk


User avatar
New member

Posts

Joined
Tue May 11, 2010 7:00 pm
Location - Manchester, England

Post by knightcat » Thu Oct 07, 2010 2:34 am

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...

Newbie

Posts

Joined
Wed Oct 06, 2010 6:02 pm

Post by dannydaman9 » Thu Oct 07, 2010 4:55 pm

Can you show some on the code so i can get an idea of how it is working?

Thanks

Site finished:
Image
http://www.labelstogo.co.uk


User avatar
New member

Posts

Joined
Tue May 11, 2010 7:00 pm
Location - Manchester, England

Post by knightcat » Thu Oct 07, 2010 10:34 pm

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... :(

Newbie

Posts

Joined
Wed Oct 06, 2010 6:02 pm

Post by dannydaman9 » Fri Oct 08, 2010 12:00 am

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

Site finished:
Image
http://www.labelstogo.co.uk


User avatar
New member

Posts

Joined
Tue May 11, 2010 7:00 pm
Location - Manchester, England

Post by qahar » Fri Oct 08, 2010 11:04 am

Try this solution: css dropdown header menu
See my signature for tutorial collection on forum, may be help you in future.

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia
Who is online

Users browsing this forum: No registered users and 42 guests