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

Как перенести Категории в область header шаблона?


Recommended Posts

  • 1 month later...

Присоединяюсь к вопросу. На форуме сказано что нужно сгделать следующие

I've solved in this way:

1. Open catalog/controller/common/header.php adding these lines of code:

protected function getCategories($parent_id, $current_path = '') {                    $output = '';                    $results = $this->model_catalog_category->getCategories($parent_id);                    if ($results) {                            $output .= '[list]';            }                    foreach ($results as $result) {                            if (!$current_path) {                                    $new_path = $result['category_id'];                            } else {                                    $new_path = $current_path . '_' . $result['category_id'];                            }                            $output .= '[*]';                            $children = '';                    //      if ($category_id == $result['category_id']) {                                    $children = $this->getCategories($result['category_id'], $new_path);                    //      }                            if ($this->category_id == $result['category_id']) {                                    $output .= '<a href="' . $this->model_tool_seo_url->rewrite($this->url->http('product/category&path=' . $new_path))  . '">[b]' . $result['name'] . '[/b]</a>';                            } else {                                    $output .= '<a href="' . $this->model_tool_seo_url->rewrite($this->url->http('product/category&path=' . $new_path))  . '">' . $result['name'] . '</a>';                            }                    $output .= $children;                    $output .= '';                    }                    if ($results) {                            $output .= '[/list]';                    }            return $output;            }

2. in function index() in the same file add this code:

       $this->data['category'] = $this->getCategories(0);

я не совсем понял именно в какую часть или после чего все это всивлять, объясните пожалуйси :)

Edited by Guest
edit -> save
Link to comment
Share on other sites

Как я понимаю особых сложностей не должно быть , контроллеры трогать не надо .1. Иещёте в файле шаблона : catalog/..../common/header.php -строки ггде прописываются переменные кот.выводятся в нужном блоке и кот.нужно заменить.например: главная-спец.предл.-вход 2. В файле который выводит категории в потому чтоковом модуле , копируете функциональный блок - цикл вывода категорий , и всивляете в файл п.1 с заменой ненужных строк.3. возможно нужна дорилитка , чтобы категории выводились в строку а не вертикально .

Link to comment
Share on other sites


  • 1 month later...

Ксити, если кому-то понадобится сгделать выпадаюещёе меню (drop-down) неограниченной вложенности, то попробуйте использовать рекурсивную функцию карты сайи. Точно сгделать уже не помню как (не понадобилось), но направление понять можно.

Link to comment
Share on other sites


  • 9 months later...

Ксити, если кому-то понадобится сгделать выпадаюещёе меню (drop-down) неограниченной вложенности, то попробуйте использовать рекурсивную функцию карты сайи. Точно сгделать уже не помню как (не понадобилось), но направление понять можно.

Ребят может кто подскажет как по нормальному это сгделать?
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

  • Recently Browsing   0 members

    • No registered users viewing this page.

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