Post by topy » Fri Jun 04, 2021 1:12 pm

Please help me to fix the level 3 on my main menu:

This is the code for header.php:

Code: Select all

// 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']) {
				if ($category['image']) {
          $image = $this->model_tool_image->resize($category['image'], 30, 30);
        } else {
          $image = $this->model_tool_image->resize('no_image.png', 30, 30);
        }
			
				$children_data = array();

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

			foreach ($children as $child) {
                    $filter_data = array();
                    $filter_data2 = array();
                    $children_data2 = array(); 
                    $children2 = $this->model_catalog_category->getCategories($child['category_id']); 
             
                    foreach ($children2 as $child2) {
                        $filter_data2 = array(
                            'filter_category_id'  => $child2['category_id'],
                            'filter_sub_category' => true
                        );
                        $children_data2[] = array(
                        'name'  => $child2['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data2) . ')' : ''),
                        'href'  => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'] . '_' . $child2['category_id']),
                        );
                    }
                 
                    $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']),
                        'children' => $children_data2,
                    );
				}

				$data['categories'][] = array(
				'thumb' => $image,
					'name'     => $category['name'],
					'children' => $children_data,
					'column'   => $category['column'] ? $category['column'] : 1,
					'href'     => $this->url->link('product/category', 'path=' . $category['category_id'])
				);
			}
		}
This is the code for header.twig:

Code: Select all

{% if categories %}
								{% for category in categories %} 
                                {% if category.children %}
                                 <li class="menu-link">
                                    <a href="{{ category['href'] }}" data-toggle="dropdown" class="dropdown-toggle"><img src="{{ category['thumb'] }}" class="imgmenucat" loading="lazy" alt="{{ category['name'] }}" title="{{ category['name'] }}" />{{ category['name'] }}</a><span class="mobile-plus"><i class="fas fa-chevron-down"></i></span>
                                 {% for children in category.children|batch(category.children|length / category.column|round(1, 'ceil')) %}
                                    <ul class="dropdown-menu sub-block">
                                       <li><a href="{{ category['href'] }}" class="see-all">{{ text_all }} {{ category['name'] }}</a></li>
                                       <li role="separator" class="divider"></li>
                                      {% for child in children %}
                                         {% if child.children %}
                                       <li class="submenu-link">
                                          <a href="{{ child['href'] }}" data-toggle="dropdown" class="dropdown-toggle">{{ child['name'] }}</a><span class="mobile-plus"><i class="fas fa-chevron-down"></i></span>
                                          <ul class="dropdown-menu sub-block">
                                             <li><a href="{{ child['href'] }}" class="see-all">{{ text_all }} {{ child['name'] }}</a></li>
                                             <li role="separator" class="divider"></li>
                                                  {% for children in child.children %}
                                             <li><a href="{{ child['href'] }}">{{ child['name'] }}</a></li>
                                              {% endfor %}    
                                          </ul>
                                       </li>
                                            {% else %}
                                       <li><a href="{{ child['href'] }}">{{ child['name'] }}</a></li>
                                    {% endif %}
                                        {% endfor %}    
                                    </ul>
                                   {% endfor %}     	
                                 </li>
                                {% else %}
                                 <li class="menu-link"><a href="{{ category['href'] }}"><img src="{{ category['thumb'] }}" class="imgmenucat" loading="lazy" alt="{{ category['name'] }}" title="{{ category['name'] }}"/>{{ category['name'] }}</a></li>
                                 {% endif %}
                                  {% endfor %}     			  			  			  
                    {% endif %}
But when child2 have subcategories it doesn't show me the child3 level... it only duplicate the child2 as child3... why? Can anyone help me to fix it pls?

Thanks in advance..

Active Member

Posts

Joined
Mon Jun 20, 2011 2:52 pm

Post by straightlight » Sat Jun 05, 2021 6:06 am

OC version. Extension request.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paulfeakins » Mon Jun 07, 2021 7:02 pm

topy wrote:
Fri Jun 04, 2021 1:12 pm
Please help me to fix the level 3 on my main menu:
As above you should use an extension for this.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by straightlight » Mon Jun 07, 2021 7:09 pm

Redundancy.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by topy » Wed Jun 09, 2021 1:01 pm

straightlight wrote:
Sat Jun 05, 2021 6:06 am
OC version. Extension request.
Opencart 3.0.3.1 -> i have installed this template ( https://www.opencart.com/index.php?rout ... =58&page=2 ) and i did changes for my needs but on mobile it's a little problem on level 3 and i don't know why.

I have all sub-categories which has another subcategories, but seems to be repeated: http://prntscr.com/14tu2w0

Active Member

Posts

Joined
Mon Jun 20, 2011 2:52 pm

Post by topy » Wed Jun 09, 2021 1:03 pm

paulfeakins wrote:
Mon Jun 07, 2021 7:02 pm
topy wrote:
Fri Jun 04, 2021 1:12 pm
Please help me to fix the level 3 on my main menu:
As above you should use an extension for this.
An extension i think is not required for me ... because my menu ( only mobile ) is loaded from header.php not from menu.php

Active Member

Posts

Joined
Mon Jun 20, 2011 2:52 pm

Post by straightlight » Wed Jun 09, 2021 6:14 pm

topy wrote:
Wed Jun 09, 2021 1:01 pm
straightlight wrote:
Sat Jun 05, 2021 6:06 am
OC version. Extension request.
Opencart 3.0.3.1 -> i have installed this template ( https://www.opencart.com/index.php?rout ... =58&page=2 ) and i did changes for my needs but on mobile it's a little problem on level 3 and i don't know why.

I have all sub-categories which has another subcategories, but seems to be repeated: http://prntscr.com/14tu2w0
Contact the extension theme developer to resolve this issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 398 guests