Jump to content

Recommended Posts

Всем привет,

не могу разобраться с выводом 3-го уровня категорий в вертикальном меню...

Версия ocstore 1.0.1

Поиском нашел 2 варианта,

http://rb.labtodo.com/page/opencart-1512-modul-kategorij-tretij-uroven-bez-optimizacii-zaprosov

http://ow-s.com/interesnye-stati/81-dobavlenie-opencart-1513-tretego-urovnya-menyu-v-module-category-.html

ни один не работает... помогите плиз..

Share this post


Link to post
Share on other sites

У меня получилось по второму варианту (версия 1.5.3.1) http://ow-s.com/interesnye-stati/81-dobavlenie-opencart-1513-tretego-urovnya-menyu-v-module-category-.html, только я сделала изменения. Выглядит так:

В файле catalog/controller/module/category.php

после кода

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;

}

вместо кода

foreach ($children as $child) {

$data = array(

'filter_category_id' => $child['category_id'],

'filter_sub_category' => true

);

if ($setting['count']) {

$product_total = $this->model_catalog_product->getTotalProducts($data);

$children_data[] = array(

'category_id' => $child['category_id'],

'name' => $child['name'] . ' (' . $product_total . ')',

'href' => $this->url->link('product/category', 'path=' . $category['category_id'] . '_' . $child['category_id'])

);

} else {

$children_data[] = array(

'category_id' => $child['category_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

);

if ($setting['count']) {

$product_total = $this->model_catalog_product->getTotalProducts($data);

$this->data['categories'][] = array(

'category_id' => $category['category_id'],

'name' => $category['name'] . ' (' . $product_total . ')',

'children' => $children_data,

'href' => $this->url->link('product/category', 'path=' . $category['category_id'])

);

} else {

$this->data['categories'][] = array(

'category_id' => $category['category_id'],

'name' => $category['name'],

'children' => $children_data,

'href' => $this->url->link('product/category', 'path=' . $category['category_id'])

);

}

}

вставляем этот код (здесь немного меняла)

foreach ($categories as $category) {

$children_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(count($sisters) > 1) {

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'])

);

}

}

в файле cataloge/view/theme/ ваша тема /template/module/category.tpl

после кода

<?php foreach ($category['children'] as $child) { ?>

<li>

<?php if ($child['category_id'] == $child_id) { ?>

<a href="/<?php echo $child['href']; ?>"> - <?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 } ?>

Ну и в стилях немного поправила, но это уже под Вашу тему нужно подбирать.

Share this post


Link to post
Share on other sites

Как не пробовал, не помогло((( может кто нить готовый tpl и php выложить?

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.

Sign in to follow this  

  • 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.