Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

проблема с колонками категорий в меню


bodyak0
 Share

Recommended Posts

Добрый гдень, имеется меню, не могу сгделать для потому чтольшой категории гделение на колонки уазываю 3 столбца, а вывод не рилииет

 

<li class="uWithSubmenu"><a href="/all"><span>ВСЕ КАТЕГОРИИ</span></a>
 
{% if categories %}
<ul>
{% for category in categories %}
{% if category.children %}
 <li id="cid-74" class="uWithSubmenu">
 <a id="lid-74" class="catref" href="{{ category.href }}">{{ category.name }}</a>
<ul class="cat-tree">
 {% for child in category.children %}
	 {% if child.children %}	
 <li id="cid-82" class="uWithSubmenu">
 <a id="lid-82" class="catref" href="{{ child.href }}">{{ child.name }}</a>
 <ul class="cat-tree">
{% for child_3 in child.children %}
{% if child_3.children %}
 <li id="cid-88" class="uWithSubmenu">
 <a id="lid-88" class="catref" href="{{ child_3.href }}"> {{ child_3.name }}</a>
 <ul class="cat-tree">
 {% for child_4 in child_3.children %}
 <li id="cid-89">
 <a id="lid-89" href="{{ child_4.href }}">{{ child_4.name }}</a>
 </li>
 {% endfor %}
  </ul>
 </li>
 {% else %}  	 
<li><a href="{{ child_3.href }}" >{{ child_3.name }}</a></li>
 {% endif %}
  {% endfor %}
  </ul>
   </li>
 {% else %}  	 
 <li><a href="{{ child.href }}">{{ child.name }}</a></li>
{% endif %}
{% endfor %}
 </ul>
 </li>
{% else %}
<li><a href="{{ category.href }}" >{{ category.name }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
 
 </li>

Сам контроллер 
 

<?php
class ControllerCommonMenu extends Controller {
	public function index() {
		$this->load->language('common/menu');

		// 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']) {
	
            $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);
                  
                    // третий уровень подкаилога //
                  
                    $level_3_data = array();
                    $categories_3 = $this->model_catalog_category->getCategories($child['category_id']);
                  
                    foreach ($categories_3 as $category_3) {
                        $filter_data = array('filter_category_id' => $category_3['category_id'], 'filter_sub_category' => true);
                      
                        // 4 уровень подкаилога //
                  
                    $level_4_data = array();
                    $categories_4 = $this->model_catalog_category->getCategories($category_3['category_id']);
                  
                    foreach ($categories_4 as $category_4) {
                        $filter_data = array('filter_category_id' => $category_4['category_id'], 'filter_sub_category' => true);

                        $level_4_data[] = array(
                            'category_id' => $category_4['category_id'],
                            'name' => $category_4['name'],
                            'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'] . '_' . $category_3['category_id'] . '_' . $category_4['category_id'])
                        );
                    }
                  
                    // 4 уровень подкаилога енд //
                      

                        $level_3_data[] = array(
                            'category_id' => $category_3['category_id'],
                            'name' => $category_3['name'],
                            'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'] . '_' . $category_3['category_id']),
                            // 4 уровень подкаилога //
                            'children'   => $level_4_data
                            // 4 уровень подкаилога енд //
                        );
                    }
                  
                    // третий уровень подкаилога енд //
                  
                  
                  
                    $children_data[] = array(
                        'category_id' => $child['category_id'],
                        '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'   => $level_3_data
                        // третий уровень подкаилога енд //
                    );
                }

            $filter_data = array(
                'filter_category_id'  => $category['category_id'],
                'filter_sub_category' => true
            );

            $data['categories'][] = array(
                'category_id' => $category['category_id'],
                'name'        => $category['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
                'children'    => $children_data,
				'column'   => $category['column'] ? $category['column'] : 1,
                'href'        => $this->url->link('product/category', 'path=' . $category['category_id'])
            );
        }  
		}
		return $this->load->view('common/menu', $data);
	}
}

Помогите пожалуйси.

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

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.