Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

vasyagr

Newbie
  
  • Posts

    1
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

vasyagr's Achievements

Apprentice

Apprentice (3/14)

  • Dedicated Rare
  • First Post
  • Conversation Starter
  • Week One Done
  • One Month Later

Recent Badges

0

Reputation

  1. Как правильно вывести списком все категории, без учета родителя, но только те, где стоит чек "выводить на главной". Сделал правки в контролере - выводит списком все категории которые обозначены, но первую дочернюю выводит 2 раза, коггда выставлен 'top' на 2 или более дочерних категориях . $data['categories'] = array(); $categories = $this->model_catalog_category->getCategories(0); foreach ($categories as $category) { $children_data = array(); $children = $this->model_catalog_category->getCategories($category['category_id']); foreach ($children as $child) { if ($child['top']) { $filter_data = array( 'filter_category_id' => $child['category_id'], 'filter_sub_category' => true ); if ($child['image2']) { $image2 = $this->model_tool_image->resize($child['image2'], 150, 150); } else { $image2 = $this->model_tool_image->resize('placeholder.png', 150, 150); } $children_data[] = array( 'name' => $child['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''), 'image2' => $image2, 'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id']) ); $data['categories'][] = array( 'children' => $children_data ); } } if ($category['top']) { if ($category['image']) { $image = $this->model_tool_image->resize($category['image'], 150, 150); } else { $image = $this->model_tool_image->resize('placeholder.png', 150, 150); } if ($category['image2']) { $image2 = $this->model_tool_image->resize($category['image2'], 150, 150); } else { $image2 = $this->model_tool_image->resize('placeholder.png', 150, 150); } // Level 1 $data['categories'][] = array( 'name' => $category['name'], 'image' => $image, 'image2' => $image2, 'href' => $this->url->link('product/category', 'path=' . $category['category_id']) ); } Шаблон {% for category in categories %} {% if category.children %} {% for children in category.children|batch(category.children|length ) %} {% for child in children %} <div> <a href="{{ child.href }}"> <div><img src="{{ child.image2 }}" /></div> <div>{{ child.name }}</div> </a> </div> {% endfor %} {% endfor %} {% else %} <div> <a href="{{ category.href }}"> <div><img src="{{ category.image2 }}" /></div> <div >{{ category.name }}</div> </a> </div> {% endif %} {% endfor %}
Guest
×
  • 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.