Добрый день, может кто подсказать как решить мою проблему
Есть модуль, который выводит кастомные ссылки как меню
вывод на фронт такой
в газовых есть тоже меню
и выводит оно их вот так
мне нужно чтобы он выводил не только из вкладки "меню", но и из других тоже
контроллер данной структуры( с меню):
<?php
class ControllerCommonCustomMenu extends Controller {
private $tree_data;
private function makeTree($category_id) {
$categories = $this->model_catalog_category->getCategories($category_id);
foreach ($categories as $category_data) {
$this->tree_data[$category_data['category_id']] = $category_data;
$this->tree_data[$category_data['category_id']]['parent_id'] = $category_id;
$this->tree_data[$category_id]['children'][] = &$this->tree_data[$category_data['category_id']];
$this->makeTree($category_data['category_id']);
}
}
public function index() {
$data['menu_items'] = $this->makeCustomMenu();
$data['thisUri'] = $_SERVER['REQUEST_URI'];
return $this->load->view('common/custom_menu', $data);
}
public function makeCustomMenu() {
$this->load->language('common/menu');
$this->load->model('catalog/category');
$this->load->model('catalog/product');
$data['text_categories'] = $this->language->get('text_categories');
if (isset($this->request->get['path'])) {
$parts = explode('_', (string)$this->request->get['path']);
} else {
$parts = array();
}
$this->tree_data[] = array('name' => 'root', 'category_id' => 0);
$this->makeTree(0, array(), $parts);
$this->load->model('catalog/category');
$custom_menu_items = array();
foreach ($this->tree_data[0]['children'] as $tree_item) {
$children_data_level2 = $this->getCustomLinks($tree_item['category_id']);
$children_level2 = $this->model_catalog_category->getCategories($tree_item['category_id']);
foreach($children_level2 as $child_level2) {
$children_level3 = $this->model_catalog_category->getCategories($child_level2['category_id']);
$children_data_level3 = $this->getCustomLinks($child_level2['category_id']);
foreach($children_level3 as $child_level3) {
$children_level4 = $this->model_catalog_category->getCategories($child_level3['category_id']);
$children_data_level4 = $this->getCustomLinks($child_level3['category_id']);
foreach($children_level4 as $child_level4){
$children_data_level4 = $this->getCustomLinks($child_level4['category_id']);
$path = array($tree_item['category_id'], $child_level2['category_id'], $child_level3['category_id'], $child_level4['category_id']);
}
$path = array($tree_item['category_id'], $child_level2['category_id'], $child_level3['category_id'],);
$children_data_level3[] = $this->getCategoryLink($child_level2, $children_data_level4, $parts, $path);
}
$path = array($tree_item['category_id'], $child_level2['category_id']);
}
$path = array($tree_item['category_id']);
$custom_menu_items[] = $this->getCategoryLink($tree_item, $children_data_level2, $parts, $path);
}
$data['menu_items'] = array();
// add root menu item
$data['menu_items'][] = array(
'active' => false,
'is_category' => true,
'column' => 1,
'name' => $this->language->get('Каталог товаров'),
'children' => $custom_menu_items,
'href' => '/index.php?route=product/category&path=65'
);
return $data['menu_items'];
}
private function getCategoryLink($category_data, $children, $parts, $path) {
$filter_data = array('filter_category_id' => $category_data['category_id'], 'filter_sub_category' => true);
if (is_file(DIR_IMAGE . $category_data['image'])) {
$image = HTTPS_SERVER . 'image/' . $category_data['image'];
} else {
$image = false;
}
return array(
'category_id' => $category_data['category_id'],
'is_category' => true,
'active' => in_array($category_data['category_id'], $parts),
'imageold' => $image,
'column' => $category_data['column'] ? $category_data['column'] : 1,
'name' => $category_data['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''),
'children' => $children,
'href' => $this->url->link('product/category', 'path=' . implode('_', $path))
);
}
private function getCustomLinks($category_id) {
$results = $this->model_catalog_category->getCategoryLinks3($category_id);
$children_data = array();
foreach($results as $category_link) {
if (is_file(DIR_IMAGE . $category_link['image'])) {
$image = HTTPS_SERVER . 'image/' . $category_link['image'];
} else {
$image = false;
}
$names = unserialize($category_link['name']);
$links = unserialize($category_link['link']);
$children = array();
parse_str(html_entity_decode($links[$this->config->get('config_language_id')], ENT_QUOTES, 'UTF-8'), $link_data);
if (isset($link_data['path'])) {
$parts = explode('_', (string)$link_data['path']);
$category_id = end($parts);
$children = $this->getCustomLinks($category_id);
}
if (isset($names[$this->config->get('config_language_id')]) && isset($links[$this->config->get('config_language_id')])) {
$children_data[] = array(
'category_id' => 0,
'is_category' => false,
'active' => ($links[$this->config->get('config_language_id')] == $this->request->server['REQUEST_URI']),
'name' => $names[$this->config->get('config_language_id')],
'href' => $links[$this->config->get('config_language_id')],
'image' => $image,
'children' => $children,
'sort_order' => $category_link['sort_order'],
'target' => $category_link['target']
);
}
}
return $children_data;
}
}
Вывести в шаблон я могу самостоятельно, у меня не получается сформировать правильную структуру...
а еще чтобы выводить в категорию данные из вкладки "Подборки" использую:
$data['category_links'] = array();
$data['category_links_query'] = $this->model_catalog_category->getCategoryLinks($category_id);
$this->load->model('tool/image');
if ($category_info['costom_links1_name']) {
$data['costom_links1_name'] = $category_info['costom_links1_name'];//название подборки
}
foreach($data['category_links_query'] as $category_link) {
if (is_file(DIR_IMAGE . $category_link['image'])) {
$image = HTTPS_SERVER . 'image/' . $category_link['image'];
} else {
$image = false;
}
$names = unserialize($category_link['name']);
$links = unserialize($category_link['link']);
if (isset($names[$this->config->get('config_language_id')]) && isset($links[$this->config->get('config_language_id')])) {
$data['category_links'][] = array(
'name' => $names[$this->config->get('config_language_id')],
'link' => $links[$this->config->get('config_language_id')],
'image' => $image ,
'sort_order' => $category_link['sort_order'],
'target' => $category_link['target']
);
}
}
а потом в шаблоне
{% if category_links %}
<div class="category-links__block">
{% if costom_links1_name %}
<div class="slideToggle"><h3>{{ costom_links1_name }}</h3></div>
{% endif %}
<div class="showToggle">
<div class="category-links" style="display: flex;">
{% for category_link in category_links %}
<div class="cat-link" style="margin-right: 5px;">
<a class="category-link" href="{{ category_link.link }}" {{ category_link.target ? 'target="_blank"' }}>{% if category_link.image %}<img src="{{ category_link.image }}" />{% endif %} {{ category_link.name }}</a>
</div>
{% endfor %}
</div>
</div>
</div>
{% endif %}
Как мне в меню запихнуть и эту вкладку тоже? Помогите пожалуйста