Post by Gnutz » Fri Jun 24, 2011 7:44 am

I am new to OpenCart and I am trying to put my main menu simply in the header of the page with my desired categories running along which drop down. Currently I have Categories, Information and Best Sellers each with their own drop downs in my main menu. I don't want this, I want the categories in the Categories drop down tab to be my main menu.

Can anyone help is this is driving me a little mad. My friends OpenCart has a Header Menu module by default and it is not in mine and I can't see a module for it, if it is one but he hasn't plugged one in. I'm a little confused by this.

Newbie

Posts

Joined
Thu Jun 23, 2011 5:53 pm

Post by Jacob » Fri Jun 24, 2011 11:33 pm

I am new to OpenCart and I am trying to put my main menu simply in the header of the page with my desired categories running along which drop down.
There is not an options to do this in admin, but you can do it by editing catalog/view/theme/yourtheme/template/common/header.tpl file :

Look for this and cut it and everything inside:

Code: Select all

<?php if ($categories) { ?>
<?php } ?>
Make a new unique 'div' and paste the code inside it. Put this inside your header 'div' where you would like it to display.

Then make a new css rule in your yourtheme/stylesheet/stylesheet.css file for your new div and fine position it.

Information and Best Sellers each with their own drop downs in my main menu. I don't want this, I want the categories in the Categories drop down tab to be my main menu.
I am not sure how that got to be? Maybe have a play around in admin.

Active Member

Posts

Joined
Thu Dec 04, 2008 9:17 pm

Post by xsobakax » Wed Oct 26, 2011 5:27 am

I need "menu" in the footer of my site.
Try to edit "footer.tpl" and paste on this file this piece of code:

Code: Select all

<?php if ($categories) { ?>
<?php } ?>
And receive error about "undefined variable categories"
What am I doing wrong?

Newbie

Posts

Joined
Mon Oct 17, 2011 4:27 pm

Post by uksitebuilder » Wed Oct 26, 2011 3:03 pm

You can't just paste content from one .tpl to another (well not in most cases)

You need to also look at where the data comes from (the controller file associate with the .tpl)

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by xsobakax » Thu Oct 27, 2011 1:23 am

OK,
maybe u know easier way to make double menu - in header and in footer?...
I thought it's so easy, but was wrong.

Newbie

Posts

Joined
Mon Oct 17, 2011 4:27 pm

Post by uksitebuilder » Thu Oct 27, 2011 1:42 am

the problem will be that the header menu slides down when hovered.

the effect of this when it is in the footer will not function well.

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by xsobakax » Thu Oct 27, 2011 4:06 am

I'll agree on simple menu without "children" categories... Just the main.
But how can I create it?

Newbie

Posts

Joined
Mon Oct 17, 2011 4:27 pm

Post by uksitebuilder » Thu Oct 27, 2011 4:39 am

then you need to copy the whole menu/categories block from the catalog/controller/common/header.php to catalog/controller/common/footer.php

Code: Select all

		// Menu
		$this->load->model('catalog/category');
		$this->load->model('catalog/product');
		
		$this->data['categories'] = array();
					
		$categories = $this->model_catalog_category->getCategories(0);
		
		foreach ($categories as $category) {
			if ($category['top']) {
				$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(
						'name'  => $child['name'] . ' (' . $product_total . ')',
						'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])	
					);					
				}
				
				// Level 1
				$this->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'])
				);
			}
		}
Then you can copy the menu code from header.tpl to footer.tpl

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by xsobakax » Fri Oct 28, 2011 4:46 am

WOW!
many thanks! it works! great! ))

Newbie

Posts

Joined
Mon Oct 17, 2011 4:27 pm
Who is online

Users browsing this forum: No registered users and 13 guests