Page 1 of 2

Sub sub-categories in menu?

Posted: Tue Oct 04, 2011 2:42 am
by TimJr2.0
I'm sure its possible but can't seem to figure it out. I noticed that the top categories display on the menu, then the sub categories appear as a drop down list of each parent category.

What I want to achieve is the sub-category of a sub-category shown in the drop down list as well.

food>burger>cheese burger
top category: food
sub category: burger
sub>sub category: cheese burger ( this is what i want to display )

Code: Select all

<div id="menu">
  <ul>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><span><?php echo $category['name']; ?></span></a>
      <?php if ($category['children']) { ?>
      <div>
        <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>
          <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
  </ul>
</div>
<?php } ?></div>

I could actually call the database and retrieve it, but that would severly slow down the site as it would need to do it ever time the page loads.

Code: Select all

<?php echo $category['children'][$i]['name']; ?>
if someone could point me in the right direction, I would really appreciate it.

Re: Sub sub-categories in menu?

Posted: Tue Oct 04, 2011 9:05 pm
by TimJr2.0
Never mind, I had to rewrite the entire category section controller/common/header.php,
because the header did not allow 3rd tier categories.
But I found the code in controller/information/sitemap.php to be quite helpful.

I'll post a link once I'm finished.

Success: Sub sub-categories in menu

Posted: Fri Oct 07, 2011 3:51 am
by TimJr2.0
Ok, take a look and tell me what you think about the menu!

http://sounddoctorshop.com - the sites still under development of course.

Re: Sub sub-categories in menu?

Posted: Fri Oct 07, 2011 9:32 am
by purplewac
Looks great and just what we have been looking to do as well.
Your sub category links do not appear to be working correctly though.
If you select sub category 1 (under stereos), it goes to CD Players and not sub category 1.

Re: Sub sub-categories in menu?

Posted: Fri Oct 07, 2011 11:27 am
by TimJr2.0
Thanks, also sorry about that, I have seo urls enabled and had not set the keyword (because I planned to change it anyways) for any of the sub-sub categories.

I added a few keywords, so now the sub-sub categories will work under "stereos" and "amplifiers-amps".

Re: Sub sub-categories in menu?

Posted: Fri Oct 07, 2011 1:08 pm
by purplewac
That works well now.
The sub sub category text is extending out of the drop down box to the right in ie8 though.

Any chance of you sharing your code for this when you get a chance?

Re: Sub sub-categories in menu?

Posted: Sat Oct 08, 2011 12:12 am
by TimJr2.0
That's odd, I have ie8.0.6 and it looks fine. Could you get a screen shot?

Sure thing, remember to back up your files.
Also note that it will not look correctly without some styling.

locate: catalog/controller/common/header.php

find:

Code: Select all

		$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'])
				);
			}
		}
replace it with this code ( I removed the product total ):

Code: Select all

//below is written to enable 3rd level sub-categories

		$categories_1 = $this->model_catalog_category->getCategories(0);
		
		foreach ($categories_1 as $category_1) {
			$level_2_data = array();
			
			$categories_2 = $this->model_catalog_category->getCategories($category_1['category_id']);
			
			foreach ($categories_2 as $category_2) {
				$level_3_data = array();
				
				$categories_3 = $this->model_catalog_category->getCategories($category_2['category_id']);
				
				foreach ($categories_3 as $category_3) {
					$level_3_data[] = array(
						'name' => $category_3['name'],
                              			'column'   => $category_3['column'] ? $category_3['column'] : 1,
						'href' => $this->url->link('product/category', 'path=' . $category_1['category_id'] . '_' . $category_2['category_id'] . '_' . $category_3['category_id'])
					);
				}
				
				$level_2_data[] = array(
					'name'     => $category_2['name'],
					'children' => $level_3_data,
					'href'     => $this->url->link('product/category', 'path=' . $category_1['category_id'] . '_' . $category_2['category_id'])	
				);					
			}
			
			$this->data['categories'][] = array(
				'name'     => $category_1['name'],
				'children' => $level_2_data,
				'column'   => $category_1['column'] ? $category_1['column'] : 1,
				'href'     => $this->url->link('product/category', 'path=' . $category_1['category_id'])
			);
		}

// End of the written addition
locate: your themes header.tpl

find:

Code: Select all

<?php if ($categories) { ?>
<div id="menu">
  <ul>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
      <?php if ($category['children']) { ?>
      <div>
        <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>
          <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
  </ul>
</div>
<?php } ?>
replace it with:

Code: Select all

<?php if ($categories) { ?>
<div id="menu">
  <ul>
    <?php foreach ($categories as $category_1) { ?>
    <li><a href="<?php echo $category_1['href']; ?>" class="<?php if (!$category_1['children']) { ?>oc-single<?php } ?>"><span><?php echo $category_1['name']; ?></span></a>
      <?php if ($category_1['children']) { ?>
      <div>
       <?php $w = count($category_1['children']) * 180; // this value depends on the width of each div ?>
        <div class="oc-outer" style="width:<?php echo $w; ?>px;">
       <?php foreach($category_1['children'] as $category_2) { ?>
        <div class="oc-left">
         <h1 style="min-width:165px">
          <a href="<?php echo $category_2['href']; ?>"><span><?php echo $category_2['name']; ?></span></a>
         </h1>
          <?php if ($category_2['children']) { ?>
           <ul>
            <?php foreach($category_2['children'] as $category_3) { ?>
               <li><a href="<?php echo $category_3['href']; ?>"><?php echo $category_3['name']; ?></a></li>
            <?php } ?>
           </ul>
          <?php } ?>
        </div>
       <?php } ?>
       </div>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
  </ul>
</div>
<?php } ?>
now for the styling:

Code: Select all

#menu > ul > li:hover > a.oc-single {
    background: url("../image/oc-menu-item-h3.png") no-repeat scroll left top transparent;
    color: #444;
}
#menu > ul > li:hover > a.oc-single > span {
    background: url("../image/oc-menu-item-h3.png") no-repeat scroll right top transparent;
    color: #444;
}
.oc-left {
        float:left;
        padding-left:10px
}
.oc-left > h1 {
        font-size:14px;
        margin-bottom:5px;
}
.oc-left > h1 > a {
        text-decoration:none;
        font-size:14px;
        font-weight:bold;
        font-family: arial,helvetica,sanserif;
        text-transform: uppercase;
}
That just about rounds it up.

I worked with wordpress for some time and I kinda would like to see child themes concept brought to opencart, so I don't have to modify core files just to update the version and lose all modifications.

Re: Sub sub-categories in menu?

Posted: Mon Oct 10, 2011 1:57 pm
by purplewac
Thank you very much for the code, it works great so far.
Had a few problems with the styling but getting there.

I have attached a screen shot of the problem on your site, but wouldn't worry too much about it.
The browser is IE8.0.6, but I have found that it seems to display quite a few things weird compared to other versions including IE8 on other machines, so could be a local problem.

Re: Sub sub-categories in menu?

Posted: Mon Oct 10, 2011 4:12 pm
by TimJr2.0
Your welcome, and thanks for the screenshot.
IE8 has a "compatibility view" feature next to the address bar, beside the refresh button.
The icon looks like a torn page.
Un-click that and this problem ceases to exist.
( you may have clicked it while viewing an older webpage/site, which fixes old sites but, it breaks newer webpages )

Re: Sub sub-categories in menu?

Posted: Tue Dec 20, 2011 4:08 pm
by mantisviii
Hi,

After implementing this, you cannot hide specific categories in the top bar.
Even without clicking "add to topbar", all categories are shown.
Is there anyone that can help?

Re: Sub sub-categories in menu?

Posted: Sun Jan 29, 2012 4:55 am
by nobb
subsubcategory1.png

subsubcategory1.png (26.39 KiB) Viewed 118859 times

thanks bud, but can you fix category at sidebar box? :ponder:
im sory for my bad english

thanks buddy ;)

Re: Sub sub-categories in menu?

Posted: Sat Mar 10, 2012 7:33 pm
by mro
Thanks for this - just what I was looking for

Mro

Re: Sub sub-categories in menu?

Posted: Tue Apr 03, 2012 5:41 pm
by Beeflowers
Thank you, appreciate your time and effort for this. I had been longing for a layout like this for the longest time.

Re: Sub sub-categories in menu?

Posted: Sat Apr 07, 2012 4:22 am
by xseon
nobb wrote:
subsubcategory1.png
thanks bud, but can you fix category at sidebar box? :ponder:
im sory for my bad english

thanks buddy ;)
Have a look at Deeper and Better Category Module ;)

It is configurable to show or not the top level categories and has one more level of subcategories.

Re: Sub sub-categories in menu?

Posted: Wed Jun 20, 2012 10:29 pm
by kagi
I can't thank you enough for providing this mod. The styling took a bit of time and I also tweaked with some of the logic, but this is exactly what I need. And trust me, I have looked and looked to resolve sub sub categories in the menu for days now.

Thank you again!!

Re: Sub sub-categories in menu?

Posted: Wed Jul 11, 2012 2:10 pm
by sampras
Hello, i want to add custom links as 1st level and 2nd level category along with all the other categories in this menu. Can someone please instruct me to do this? i suppose its not that difficult.

Re: Sub sub-categories in menu?

Posted: Thu Jul 12, 2012 11:56 pm
by electrocasnica.ro
Same request as Sampras.
How can I add sub sub categories in the menu navbar, just like purplewac has?
I tried with the code provided from TimJr2.0 but it doesn't work for me.

Thanks

Re: Sub sub-categories in menu?

Posted: Fri Dec 28, 2012 6:05 am
by electronicsandmore
hello, I hope this helps..

Please make sure you backup you're files before editing them!!!!!!

in /upload/catalog/controller/module change the whole category.php file to the following..

Code: Select all

<?php 
class ControllerModuleCategory extends Controller {
   protected function index() {
      $this->language->load('module/category');
      
       $this->data['heading_title'] = $this->language->get('heading_title');
      
      if (isset($this->request->get['path'])) {
         $parts = explode('_', (string)$this->request->get['path']);
      } else {
         $parts = array();
      }
      
      if (isset($parts[0])) {
         $this->data['category_id'] = $parts[0];
      } else {
         $this->data['category_id'] = 0;
      }
      
      if (isset($parts[1])) {
         $this->data['child_id'] = $parts[1];
      } else {
         $this->data['child_id'] = 0;
      }
            if (isset($parts[2])) {
         $this->data['sisters_id'] = $parts[2];
      } else {
         $this->data['sisters_id'] = 0;
      }         
      $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) {
         
             $children_data = array();
          $sister_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($sisters) {
                   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'])
             );
          }
      
      if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/category.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/module/category.tpl';
      } else {
         $this->template = 'default/template/module/category.tpl';
      }
      
      $this->render();
     }
}
?>
in /upload/admin/view/template/module change the file category.tpl to the following

Code: Select all

<div class="box">
  <div class="box-heading"><?php echo $heading_title; ?></div>
  <div class="box-content">
    <div class="box-category">
      <ul>
        <?php foreach ($categories as $category) { ?>
        <li>
          <?php if ($category['category_id'] == $category_id) { ?>
          <a href="<?php echo $category['href']; ?>" class="active"><?php echo $category['name']; ?></a>
          <?php } else { ?>
          <a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
          <?php } ?>
          <?php if ($category['children']) { ?>
          <ul>
            <?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 } ?>
                  <?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 } ?>
           </li>
            <?php } ?>
          </ul>
          <?php } ?>
        </li>
        <?php } ?>
      </ul>
    </div>
  </div>
</div>
in upload/admin/view/stylesheet under...

Code: Select all

.box-category > ul > li ul {
	display: none;
}
.box-category > ul > li a.active {
	font-weight: bold;
Add the following..

Code: Select all

.box-category > ul > li a.active + ul {
	display: block;
}
.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;
}
Now that should solve your side sub categories.. Check this now..

Then follow the next post..

Re: Sub sub-categories in menu?

Posted: Fri Dec 28, 2012 6:20 am
by electronicsandmore
Now the follow on from my previous post.. This should change the top menu to display sub categories..

You may need to post these into a notepad then save them as either header.php or header.tpl MAKE SURE YOU ADD THE .PHP OR .TPL AS THIS WILL CHANGE THE FILE. Then download vqmod and install that to your website, But for now try the following..

MAKE SURE YOU BACK UP FILES BEFORE CHANGING THEM!!

in \catalog\controller\common change header.php file to..

Code: Select all

<?php   
class ControllerCommonHeader extends Controller {
	protected function index() {
		$this->data['title'] = $this->document->getTitle();
		
		if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
			$this->data['base'] = $this->config->get('config_ssl');
		} else {
			$this->data['base'] = $this->config->get('config_url');
		}
		
		$this->data['description'] = $this->document->getDescription();
		$this->data['keywords'] = $this->document->getKeywords();
		$this->data['links'] = $this->document->getLinks();	 
		$this->data['styles'] = $this->document->getStyles();
		$this->data['scripts'] = $this->document->getScripts();
		$this->data['lang'] = $this->language->get('code');
		$this->data['direction'] = $this->language->get('direction');
		$this->data['google_analytics'] = html_entity_decode($this->config->get('config_google_analytics'), ENT_QUOTES, 'UTF-8');

		// Whos Online
		if ($this->config->get('config_customer_online')) {
			$this->load->model('tool/online');
	
			if (isset($this->request->server['REMOTE_ADDR'])) {
				$ip = $this->request->server['REMOTE_ADDR'];	
			} else {
				$ip = ''; 
			}
			
			if (isset($this->request->server['HTTP_HOST']) && isset($this->request->server['REQUEST_URI'])) {
				$url = 'http://' . $this->request->server['HTTP_HOST'] . $this->request->server['REQUEST_URI'];	
			} else {
				$url = '';
			}
			
			if (isset($this->request->server['HTTP_REFERER'])) {
				$referer = $this->request->server['HTTP_REFERER'];	
			} else {
				$referer = '';
			}
						
			$this->model_tool_online->whosonline($ip, $this->customer->getId(), $url, $referer);
		}
				
		$this->language->load('common/header');
		
		if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
			$server = HTTPS_IMAGE;
		} else {
			$server = HTTP_IMAGE;
		}	
				
		if ($this->config->get('config_icon') && file_exists(DIR_IMAGE . $this->config->get('config_icon'))) {
			$this->data['icon'] = $server . $this->config->get('config_icon');
		} else {
			$this->data['icon'] = '';
		}
		
		$this->data['name'] = $this->config->get('config_name');
				
		if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) {
			$this->data['logo'] = $server . $this->config->get('config_logo');
		} else {
			$this->data['logo'] = '';
		}
		
		$this->data['text_home'] = $this->language->get('text_home');
		$this->data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), (isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0));
		$this->data['text_shopping_cart'] = $this->language->get('text_shopping_cart');
    	$this->data['text_search'] = $this->language->get('text_search');
		$this->data['text_welcome'] = sprintf($this->language->get('text_welcome'), $this->url->link('account/login', '', 'SSL'), $this->url->link('account/register', '', 'SSL'));
		$this->data['text_logged'] = sprintf($this->language->get('text_logged'), $this->url->link('account/account', '', 'SSL'), $this->customer->getFirstName(), $this->url->link('account/logout', '', 'SSL'));
		$this->data['text_account'] = $this->language->get('text_account');
    	$this->data['text_checkout'] = $this->language->get('text_checkout');
				
		$this->data['home'] = $this->url->link('common/home');
		$this->data['wishlist'] = $this->url->link('account/wishlist', '', 'SSL');
		$this->data['logged'] = $this->customer->isLogged();
		$this->data['account'] = $this->url->link('account/account', '', 'SSL');
		$this->data['shopping_cart'] = $this->url->link('checkout/cart');
		$this->data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL');
		
		if (isset($this->request->get['filter_name'])) {
			$this->data['filter_name'] = $this->request->get['filter_name'];
		} else {
			$this->data['filter_name'] = '';
		}
		
		// 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
					);					
					/*Begin of the extension Header menu add level 3 sub categories extension code  to be replaced:
					$product_total = $this->model_catalog_product->getTotalProducts($data);
									
					$children_data[] = array(
						'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $product_total . ')' : ''),
						'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])	
					);	
					*/					
					// Level 2
					$children_level2 = $this->model_catalog_category->getCategories($child['category_id']);
					$children_data_level2 = array();
					foreach ($children_level2 as $child_level2) {
							$data_level2 = array(
									'filter_category_id'  => $child_level2['category_id'],
									'filter_sub_category' => true
							);
							$product_total_level2 = '';
							if ($this->config->get('config_product_count')) {
									$product_total_level2 = ' (' . $this->model_catalog_product->getTotalProducts($data_level2) . ')';
							}

							$children_data_level2[] = array(
									'name'  =>  $child_level2['name'] . $product_total_level2,
									'href'  => $this->url->link('product/category', 'path=' . $child['category_id'] . '_' . $child_level2['category_id']),
									'id' => $category['category_id']. '_' . $child['category_id']. '_' . $child_level2['category_id']
							);
					}
					$children_data[] = array(
							'name'  => $child['name'],
							'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']),
							'id' => $category['category_id']. '_' . $child['category_id'],
							'children_level2' => $children_data_level2,
					);
					//END of the extension Header menu add level 3 sub categories extension			
				}
				
				// 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'])
				);
			}
		}
		
		$this->children = array(
			'module/language',
			'module/currency',
			'module/cart'
		);
				
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/common/header.tpl';
		} else {
			$this->template = 'default/template/common/header.tpl';
		}
		
    	$this->render();
	} 	
}
?>
In \catalog\view\theme\default\template\common change header.tpl file to...

Code: Select all

<!DOCTYPE html>
<html dir="<?php echo $direction; ?>" lang="<?php echo $lang; ?>">
<head>
<meta charset="UTF-8" />
<title><?php echo $title; ?></title>
<base href="<?php echo $base; ?>" />
<?php if ($description) { ?>
<meta name="description" content="<?php echo $description; ?>" />
<?php } ?>
<?php if ($keywords) { ?>
<meta name="keywords" content="<?php echo $keywords; ?>" />
<?php } ?>
<?php if ($icon) { ?>
<link href="<?php echo $icon; ?>" rel="icon" />
<?php } ?>
<?php foreach ($links as $link) { ?>
<link href="<?php echo $link['href']; ?>" rel="<?php echo $link['rel']; ?>" />
<?php } ?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/stylesheet.css" />
<?php foreach ($styles as $style) { ?>
<link rel="<?php echo $style['rel']; ?>" type="text/css" href="<?php echo $style['href']; ?>" media="<?php echo $style['media']; ?>" />
<?php } ?>
<script type="text/javascript" src="catalog/view/javascript/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="catalog/view/javascript/jquery/ui/jquery-ui-1.8.16.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="catalog/view/javascript/jquery/ui/themes/ui-lightness/jquery-ui-1.8.16.custom.css" />
<script type="text/javascript" src="catalog/view/javascript/jquery/ui/external/jquery.cookie.js"></script>
<script type="text/javascript" src="catalog/view/javascript/jquery/colorbox/jquery.colorbox.js"></script>
<link rel="stylesheet" type="text/css" href="catalog/view/javascript/jquery/colorbox/colorbox.css" media="screen" />
<script type="text/javascript" src="catalog/view/javascript/jquery/tabs.js"></script>
<script type="text/javascript" src="catalog/view/javascript/common.js"></script>
<?php foreach ($scripts as $script) { ?>
<script type="text/javascript" src="<?php echo $script; ?>"></script>
<?php } ?>
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/ie7.css" />
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/ie6.css" />
<script type="text/javascript" src="catalog/view/javascript/DD_belatedPNG_0.0.8a-min.js"></script>
<script type="text/javascript">
DD_belatedPNG.fix('#logo img');
</script>
<![endif]-->
<?php echo $google_analytics; ?>
</head>
<body>
<div id="container">
<div id="header">
  <?php if ($logo) { ?>
  <div id="logo"><a href="<?php echo $home; ?>"><img src="<?php echo $logo; ?>" title="<?php echo $name; ?>" alt="<?php echo $name; ?>" /></a></div>
  <?php } ?>
  <?php echo $language; ?>
  <?php echo $currency; ?>
  <?php echo $cart; ?>
  <div id="search">
    <div class="button-search"></div>
    <?php if ($filter_name) { ?>
    <input type="text" name="filter_name" value="<?php echo $filter_name; ?>" />
    <?php } else { ?>
    <input type="text" name="filter_name" value="<?php echo $text_search; ?>" onclick="this.value = '';" onkeydown="this.style.color = '#000000';" />
    <?php } ?>
  </div>
  <div id="welcome">
    <?php if (!$logged) { ?>
    <?php echo $text_welcome; ?>
    <?php } else { ?>
    <?php echo $text_logged; ?>
    <?php } ?>
  </div>
  <div class="links"><a href="<?php echo $home; ?>"><?php echo $text_home; ?></a><a href="<?php echo $wishlist; ?>" id="wishlist-total"><?php echo $text_wishlist; ?></a><a href="<?php echo $account; ?>"><?php echo $text_account; ?></a><a href="<?php echo $shopping_cart; ?>"><?php echo $text_shopping_cart; ?></a><a href="<?php echo $checkout; ?>"><?php echo $text_checkout; ?></a></div>
</div>
<?php if ($categories) { ?>
<div id="menu">
  <ul>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
      <?php if ($category['children']) { ?>
      <div>
        <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>					
				<!-- Begin Part 1 of the extension Header menu add level 3 sub categories extension (line to be replaced: number 84 of the header.tpl file) -->		
				<li>
				<?php
				if(count($category['children'][$i]['children_level2'])>0){
				?>
						<a href="<?php echo $category['children'][$i]['href']; ?>" onmouseover='JavaScript:openSubMenu("<?php echo $category['children'][$i]['id']; ?>")'><?php echo $category['children'][$i]['name']; ?>
				<?php

						echo "<img src='catalog/view/theme/default/image/arrow-right.png' style='right:10px;margin-top:3px;position:absolute;'/></a>";
						//echo "<span style='right:5px;margin-top:-6px;position:absolute;color:white;font-weight:bold;font-size:18px;'>&#187;</span></a>";

				}
				else
				{
				?>
				<a href="<?php echo $category['children'][$i]['href']; ?>" onmouseover='JavaScript:closeSubMenu()' ><?php echo $category['children'][$i]['name']; ?></a>
				<?php
				}
				?>

				<?php if ($category['children'][$i]['children_level2']) { ?>
					  <div class="submenu" id="id_menu_<?php echo $category['children'][$i]['id']; ?>">
					   <ul>
						<?php for ($wi = 0; $wi < count($category['children'][$i]['children_level2']); $wi++) { ?>
						  <li>
								<a href="<?php echo $category['children'][$i]['children_level2'][$wi]['href']; ?>"  ><?php echo $category['children'][$i]['children_level2'][$wi]['name']; ?>
								</a>
						  </li>
				  <?php } ?>
				</ul>
			  </div>
			  <?php } ?>		  
			</li>
			<!-- END Part 1 of the extension Header menu add level 3 sub categories extension -->
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
  </ul>
</div>
<?php } ?>
<div id="notification"></div>
<!-- Begin Part 2 of the extension Header menu add level 3 sub categories extension-->
<script type="text/javascript">
function openSubMenu(id){
        //
        $('.submenu').hide();
        document.getElementById("id_menu_"+id).style.display="block";
}
function closeSubMenu(){
		$('.submenu').hide();
}
</script>
<style>
.submenu{
    background: url('catalog/view/theme/default/image/menu.png') repeat scroll 0 0 transparent;
        border: 1px solid #000000;
    border-radius: 0px 5px 5px 0px;
    margin-top:-23px;
    left:140px;
    position:absolute;
    min-width:140px;
    display:none;
}
@media screen and (-webkit-min-device-pixel-ratio:0) {
 .submenu {left: 139px;}

    }
</style>
<!--[if IE 7]>
<style>
#menu > ul > li > div {
width:140px!important;
}
.submenu{
   left:145px;
}
</style>
<![endif]-->
<!--[if IE 8]>
<style>
#menu > ul > li > div {
width:140px!important;
}
.submenu{
   left:150px;
}
</style>
 <![endif]-->
 <!-- END Part 2 of the extension Header menu add level 3 sub categories extension -->
Then add the file attached (Arrow) to the following address..

\catalog\view\theme\default\image

That should solve the problem..

I have only tried this on opencart v1.5.4.1

Re: Sub sub-categories in menu?

Posted: Fri Dec 28, 2012 9:58 pm
by electronicsandmore
The file name you need to change is called category.tpl

Sorry I forgot to add that in the second file change.

in /upload/admin/view/template/module change the file category.tpl to the following