Jump to content
TheWho

3х уровневое меню ocstore 2.3

Recommended Posts

Нужно реализовать 3-х уровневое меню в ostore 2.3 , все решения из модулей попробовал, они полностью переделывают меню и скидывают стили , тема от octemplates. Кто может помочь платно, напишите в лс, или посоветуйте решение кодом, как можно адекватно эту проблему решить. Ниже прикрепил код header.php ( controller ) и header.tpl ( view ). Всех заранее благодарю за помощь.

 

		          <div class="collapse navbar-collapse navbar-ex1-collapse">
		            <ul class="nav navbar-nav flex menu">
		              <?php foreach ($categories as $item) { ?>
			              <li class="dropdown oct-mm-simplecat">
			                <a href="<?php echo $item['href']; ?>" class="dropdown-toggle" data-toggle="dropdown"><?php echo $item['name']; ?></a><?php if(count($item['children'])){ ?><a class="parent-title-toggle dropdown-toggle dropdown-img megamenu-toggle-a" data-toggle="dropdown"></a><?php } ?>
			                <div class="dropdown-menu">
			                  <div class="dropdown-inner">
			                    <ul class="list-unstyled">
			                      <?php foreach ($item['children'] as $children) { ?>
			                      <?php if ($children['children']) { ?>
			                      <li class="second-level-li has-child">
			                        <a href="<?php echo $children['href']; ?>"><?php echo $children['name']; ?></a> <?php if(count($children['children'])){ ?><?php } ?>
			                      </li>
			                      <?php } else { ?>
			                      <li class="second-level-li"><a href="<?php echo $children['href']; ?>"><?php echo $children['name']; ?></a></li>
			                      <?php } ?>
			                      <?php } ?>
			                      
			                    </ul>
			                  </div>
			                </div>
			              </li>
		              <?php } ?>
		            </ul>
		          </div>
		// Menu
		$this->load->model('catalog/category');

		$this->load->model('catalog/product');

		$data['categories'] = array();

		$categories = $this->model_catalog_category->getCategories(0);

		foreach ($categories as $category) {
			if ($category['top']) {
				// Level 2
				$children_data = array();

				$children = $this->model_catalog_category->getCategories($category['category_id']);

				foreach ($children as $child) {
					$filter_data = array(
						'filter_category_id'  => $child['category_id'],
						'filter_sub_category' => true
					);

					$children_data[] = array(
						'name'  => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
						'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])
					);
				}

				// Level 1
				$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'])
				);
			}
		}

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.