public function renderForm() { $fields_form = array('form' => array('legend' => array('title' => $this->l('Homepage categories'), 'icon' => ''), 'input' => array(array('type' => 'cat_choice', 'label' => '', 'name' => 'cats')), 'submit' => array('name' => 'submitBlockhomecats', 'title' => $this->l('Save')))); $lang = $this->context->language; if ($selectedCats = Configuration::get('MOD_BLOCKHOMECATS_CATS')) { $selectedCats = explode(',', $selectedCats); foreach ($selectedCats as $index => $id_category) { $selectedCats[$index] = new Category($id_category, $this->context->language->id); } } else { $selectedCats = null; } $helper = new HelperForm(); $helper->show_toolbar = false; $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $helper->module = $this; $helper->identifier = 'id_blocklink'; $helper->submit_action = 'submit'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->fields_value = array('text' => 'text'); $categories = Category::getNestedCategories(2, $this->context->language->id, false); $helper->tpl_vars = array('allCats' => $this->getAllCats(current($categories)), 'selectedCats' => $selectedCats); return $helper->generateForm(array($fields_form)); }
public function getData() { if (!isset($this->_data)) { $this->setData(Category::getNestedCategories($this->getRootCategory(), $this->getLang(), false, null, $this->useShopRestriction())); } return $this->_data; }
public function getData() { if (!isset($this->_data)) { $categories = Category::getNestedCategories(); $products = $this->getProductsDB(); $categories = $this->populateCategoriesWithProducts($categories, $products); $this->setData($categories); } return $this->_data; }
public function getData() { if (!isset($this->_data)) { $shop = $this->getShop(); $lang = $this->getLang(); $root_category = (int) $this->getRootCategory(); if ($this->_full_tree) { $this->setData(Category::getNestedCategories($root_category, $lang, false, null, $this->useShopRestriction())); $this->setDataSearch(Category::getAllCategoriesName($root_category, $lang, false, null, $this->useShopRestriction())); } elseif ($this->_children_only) { if (empty($root_category)) { $root_category = Category::getRootCategory()->id; } $categories[$root_category] = Category::getChildren($root_category, $lang, false, $shop->id); $children = $this->fillTree($categories, $root_category); $this->setData($children); } else { if (empty($root_category)) { $root_category = Category::getRootCategory()->id; } $new_selected_categories = array(); $selected_categories = $this->getSelectedCategories(); $categories[$root_category] = Category::getChildren($root_category, $lang, false, $shop->id); foreach ($selected_categories as $selected_category) { $category = new Category($selected_category, $lang, $shop->id); $new_selected_categories[] = $selected_category; $parents = $category->getParentsCategories($lang); foreach ($parents as $value) { $new_selected_categories[] = $value['id_category']; } } $new_selected_categories = array_unique($new_selected_categories); foreach ($new_selected_categories as $selected_category) { $current_category = Category::getChildren($selected_category, $lang, false, $shop->id); if (!empty($current_category)) { $categories[$selected_category] = $current_category; } } $tree = Category::getCategoryInformations(array($root_category), $lang); $children = $this->fillTree($categories, $root_category); if (!empty($children)) { $tree[$root_category]['children'] = $children; } $this->setData($tree); $this->setDataSearch(Category::getAllCategoriesName($root_category, $lang, false, null, $this->useShopRestriction())); } } return $this->_data; }
protected function makeMenu() { $menu_items = $this->getMenuItems(); $id_lang = (int) $this->context->language->id; $id_shop = (int) Shop::getContextShopID(); foreach ($menu_items as $item) { if (!$item) { continue; } preg_match($this->pattern, $item, $value); $id = (int) substr($item, strlen($value[1]), strlen($item)); switch (substr($item, 0, strlen($value[1]))) { case 'CAT': $this->_menu .= $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, false, $this->user_groups)); break; case 'PRD': $selected = $this->page_name == 'product' && Tools::getValue('id_product') == $id ? ' class="sfHover"' : ''; $product = new Product((int) $id, true, (int) $id_lang); if (!is_null($product->id)) { $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($product->getLink()) . '" title="' . $product->name . '">' . $product->name . '</a></li>' . PHP_EOL; } break; case 'CMS': $selected = $this->page_name == 'cms' && Tools::getValue('id_cms') == $id ? ' class="sfHover"' : ''; $cms = CMS::getLinks((int) $id_lang, array($id)); if (count($cms)) { $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($cms[0]['link']) . '" title="' . Tools::safeOutput($cms[0]['meta_title']) . '">' . Tools::safeOutput($cms[0]['meta_title']) . '</a></li>' . PHP_EOL; } break; case 'CMS_CAT': $category = new CMSCategory((int) $id, (int) $id_lang); if (count($category)) { $this->_menu .= '<li><a href="' . Tools::HtmlEntitiesUTF8($category->getLink()) . '" title="' . $category->name . '">' . $category->name . '</a>'; $this->getCMSMenuItems($category->id); $this->_menu .= '</li>' . PHP_EOL; } break; // Case to handle the option to show all Manufacturers // Case to handle the option to show all Manufacturers case 'ALLMAN': $link = new Link(); $this->_menu .= '<li><a href="' . $link->getPageLink('manufacturer') . '" title="' . $this->l('All manufacturers') . '">' . $this->l('All manufacturers') . '</a><ul>' . PHP_EOL; $manufacturers = Manufacturer::getManufacturers(); foreach ($manufacturers as $key => $manufacturer) { $this->_menu .= '<li><a href="' . $link->getManufacturerLink((int) $manufacturer['id_manufacturer'], $manufacturer['link_rewrite']) . '" title="' . Tools::safeOutput($manufacturer['name']) . '">' . Tools::safeOutput($manufacturer['name']) . '</a></li>' . PHP_EOL; } $this->_menu .= '</ul>'; break; case 'MAN': $selected = $this->page_name == 'manufacturer' && Tools::getValue('id_manufacturer') == $id ? ' class="sfHover"' : ''; $manufacturer = new Manufacturer((int) $id, (int) $id_lang); if (!is_null($manufacturer->id)) { if (intval(Configuration::get('PS_REWRITING_SETTINGS'))) { $manufacturer->link_rewrite = Tools::link_rewrite($manufacturer->name); } else { $manufacturer->link_rewrite = 0; } $link = new Link(); $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($link->getManufacturerLink((int) $id, $manufacturer->link_rewrite)) . '" title="' . Tools::safeOutput($manufacturer->name) . '">' . Tools::safeOutput($manufacturer->name) . '</a></li>' . PHP_EOL; } break; // Case to handle the option to show all Suppliers // Case to handle the option to show all Suppliers case 'ALLSUP': $link = new Link(); $this->_menu .= '<li><a href="' . $link->getPageLink('supplier') . '" title="' . $this->l('All suppliers') . '">' . $this->l('All suppliers') . '</a><ul>' . PHP_EOL; $suppliers = Supplier::getSuppliers(); foreach ($suppliers as $key => $supplier) { $this->_menu .= '<li><a href="' . $link->getSupplierLink((int) $supplier['id_supplier'], $supplier['link_rewrite']) . '" title="' . Tools::safeOutput($supplier['name']) . '">' . Tools::safeOutput($supplier['name']) . '</a></li>' . PHP_EOL; } $this->_menu .= '</ul>'; break; case 'SUP': $selected = $this->page_name == 'supplier' && Tools::getValue('id_supplier') == $id ? ' class="sfHover"' : ''; $supplier = new Supplier((int) $id, (int) $id_lang); if (!is_null($supplier->id)) { $link = new Link(); $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($link->getSupplierLink((int) $id, $supplier->link_rewrite)) . '" title="' . $supplier->name . '">' . $supplier->name . '</a></li>' . PHP_EOL; } break; case 'SHOP': $selected = $this->page_name == 'index' && $this->context->shop->id == $id ? ' class="sfHover"' : ''; $shop = new Shop((int) $id); if (Validate::isLoadedObject($shop)) { $link = new Link(); $this->_menu .= '<li' . $selected . '><a href="' . Tools::HtmlEntitiesUTF8($shop->getBaseURL()) . '" title="' . $shop->name . '">' . $shop->name . '</a></li>' . PHP_EOL; } break; case 'LNK': $link = MenuTopLinks::get((int) $id, (int) $id_lang, (int) $id_shop); if (count($link)) { if (!isset($link[0]['label']) || $link[0]['label'] == '') { $default_language = Configuration::get('PS_LANG_DEFAULT'); $link = MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int) Shop::getContextShopID()); } $this->_menu .= '<li><a href="' . Tools::HtmlEntitiesUTF8($link[0]['link']) . '"' . ($link[0]['new_window'] ? ' onclick="return !window.open(this.href);"' : '') . ' title="' . Tools::safeOutput($link[0]['label']) . '">' . Tools::safeOutput($link[0]['label']) . '</a></li>' . PHP_EOL; } break; } } }
public function displayTop() { //if (!$this->isCached('blocktopmenu2.tpl', $this->getCacheId())) //{ $this->user_groups = $this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP')); $categoryMain = current(Category::getNestedCategories(146, $this->context->language->id, true, $this->user_groups)); //$this->loadCategories(146); // $categoryComplects = new Category(129, $this->context->language->id); // $categoryWholesale = new Category(148, $this->context->language->id); // $cmsopt = new CMS(11, $this->context->language->id); $categoryComplects = current(Category::getNestedCategories(129, $this->context->language->id, true, $this->user_groups)); $categoryComplectsDecor = current(Category::getNestedCategories(198, $this->context->language->id, true, $this->user_groups)); $categoryFurniture = current(Category::getNestedCategories(7, $this->context->language->id, true, $this->user_groups)); //$this->loadCategories(7); $shop_id = (int) $this->context->shop->id; $shop_group_id = Shop::getGroupFromShop($shop_id); $item_day_id = Db::getInstance()->getValue("SELECT id_product FROM " . _DB_PREFIX_ . "product WHERE item_for_day=1 AND active=1 ORDER BY RAND()"); if ($item_day_id) { require_once dirname(dirname(__FILE__)) . '/productcomments/ProductComment.php'; $prodict_day = new Product($item_day_id, true, $this->context->language->id, $this->context->shop->id); $average = ProductComment::getAverageGrade($prodict_day->id); $cover = Product::getCover((int) $prodict_day->id, $this->context); $this->context->smarty->assign(array('priceDisplayPrecisionDay' => _PS_PRICE_DISPLAY_PRECISION_, 'have_image_day' => isset($cover['id_image']) && (int) $cover['id_image'] ? true : false, 'cover_day' => $cover, 'categoryComplects' => $categoryComplects, 'categoryComplectsDecor' => $categoryComplectsDecor, 'averageTotalDay' => round($average['grade']), 'ratingsDay' => ProductComment::getRatings((int) $prodict_day->id), 'nbCommentsDay' => (int) ProductComment::getCommentNumber((int) $prodict_day->id))); } else { $prodict_day = null; } $this->context->smarty->assign(array('prodict_day' => $prodict_day, 'prodict_day_url' => is_object($prodict_day) ? $this->context->link->getProductLink($prodict_day) : null, 'search' => Configuration::get('MOD_blocktopmenu2_SEARCH', null, $shop_group_id, $shop_id), 'categoryMain' => $categoryMain, 'categoryComplects' => $categoryComplects, 'categoryComplectsDecor' => $categoryComplectsDecor, 'categoryWholesale' => new Category(148, $this->context->language->id), 'cmsopt' => new CMS(11, $this->context->language->id), 'categoryFurniture' => $categoryFurniture)); // echo '<pre>'; var_dump($this->context->smarty->getTemplateVars('categoryMain')); echo '</pre>'; die(); //} return $this->display(__FILE__, 'blocktopmenu2.tpl', $this->getCacheId()); }
protected function makeMenu() { $root_node = $this->makeNode(['label' => null, 'type' => 'root', 'children' => []]); $menu_items = $this->getMenuItems(); $id_lang = (int) $this->context->language->id; $id_shop = (int) Shop::getContextShopID(); foreach ($menu_items as $item) { if (!$item) { continue; } preg_match($this->pattern, $item, $value); $id = (int) substr($item, strlen($value[1]), strlen($item)); switch (substr($item, 0, strlen($value[1]))) { case 'CAT': $categories = $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, false, $this->user_groups)); $root_node['children'] = array_merge($root_node['children'], $categories); break; case 'PRD': $product = new Product((int) $id, true, (int) $id_lang); if ($product->id) { $root_node['children'][] = $this->makeNode(['type' => 'product', 'page_identifier' => 'product-' . $product->id, 'label' => $product->name, 'url' => $product->getLink()]); } break; case 'CMS': $cms = CMS::getLinks((int) $id_lang, array($id)); if (count($cms)) { $root_node['children'][] = $this->makeNode(['type' => 'cms-page', 'page_identifier' => 'cms-page-' . $id, 'label' => $cms[0]['meta_title'], 'url' => $cms[0]['link']]); } break; case 'CMS_CAT': $root_node['children'][] = $this->generateCMSCategoriesMenu((int) $id, (int) $id_lang); break; // Case to handle the option to show all Manufacturers // Case to handle the option to show all Manufacturers case 'ALLMAN': $children = array_map(function ($manufacturer) use($id_lang) { return $this->makeNode(['type' => 'manufacturer', 'page_identifier' => 'manufacturer-' . $manufacturer['id_manufacturer'], 'label' => $manufacturer['name'], 'url' => $this->context->link->getManufacturerLink(new Manufacturer($manufacturer['id_manufacturer'], $id_lang), null, $id_lang)]); }, Manufacturer::getManufacturers()); $root_node['children'][] = $this->makeNode(['type' => 'manufacturers', 'page_identifier' => 'manufacturers', 'label' => $this->l('All manufacturers'), 'url' => $this->context->link->getPageLink('manufacturer'), 'children' => $children]); break; case 'MAN': $manufacturer = new Manufacturer($id, $id_lang); if ($manufacturer->id) { $root_node['children'][] = $this->makeNode(['type' => 'manufacturer', 'page_identifier' => 'manufacturer-' . $manufacturer->id, 'label' => $manufacturer->name, 'url' => $this->context->link->getManufacturerLink($manufacturer, null, $id_lang)]); } break; // Case to handle the option to show all Suppliers // Case to handle the option to show all Suppliers case 'ALLSUP': $children = array_map(function ($supplier) use($id_lang) { return $this->makeNode(['type' => 'supplier', 'page_identifier' => 'supplier-' . $supplier['id_supplier'], 'label' => $supplier['name'], 'url' => $this->context->link->getSupplierLink(new Supplier($supplier['id_supplier'], $id_lang), null, $id_lang)]); }, Supplier::getSuppliers()); $root_node['children'][] = $this->makeNode(['type' => 'suppliers', 'page_identifier' => 'suppliers', 'label' => $this->l('All suppliers'), 'url' => $this->context->link->getPageLink('supplier'), 'children' => $children]); break; case 'SUP': $supplier = new Supplier($id, $id_lang); if ($supplier->id) { $root_node['children'][] = $this->makeNode(['type' => 'supplier', 'page_identifier' => 'supplier-' . $supplier->id, 'label' => $supplier->name, 'url' => $this->context->link->getSupplierLink($supplier, null, $id_lang)]); } break; case 'SHOP': $shop = new Shop((int) $id); if (Validate::isLoadedObject($shop)) { $root_node['children'][] = $this->makeNode(['type' => 'shop', 'page_identifier' => 'shop-' . $id, 'label' => $shop->name, 'url' => $shop->getBaseURL()]); } break; case 'LNK': $link = Ps_MenuTopLinks::get($id, $id_lang, $id_shop); if (!empty($link)) { if (!isset($link[0]['label']) || $link[0]['label'] == '') { $default_language = Configuration::get('PS_LANG_DEFAULT'); $link = Ps_MenuTopLinks::get($link[0]['id_linksmenutop'], $default_language, (int) Shop::getContextShopID()); } $root_node['children'][] = $this->makeNode(['type' => 'link', 'page_identifier' => $link[0]['link'], 'label' => $link[0]['label'], 'url' => $link[0]['link'], 'open_in_new_window' => $link[0]['new_window']]); } break; } } return $this->mapTree(function ($node, $depth) { $node['depth'] = $depth; return $node; }, $root_node); }
public function renderChoicesSelect() { $spacer = str_repeat(' ', $this->spacer_size); $items = $this->getMenuItems(); $html = '<select multiple="multiple" id="availableItems" style="width: 300px; height: 160px;">'; $html .= '<optgroup label="' . $this->l('CMS') . '">'; $html .= $this->getCMSOptions(0, 1, $this->context->language->id, $items); $html .= '</optgroup>'; // BEGIN SUPPLIER $html .= '<optgroup label="' . $this->l('Supplier') . '">'; // Option to show all Suppliers $html .= '<option value="ALLSUP0">' . $this->l('All suppliers') . '</option>'; $suppliers = Supplier::getSuppliers(false, $this->context->language->id); foreach ($suppliers as $supplier) { if (!in_array('SUP' . $supplier['id_supplier'], $items)) { $html .= '<option value="SUP' . $supplier['id_supplier'] . '">' . $spacer . $supplier['name'] . '</option>'; } } $html .= '</optgroup>'; // BEGIN Manufacturer $html .= '<optgroup label="' . $this->l('Manufacturer') . '">'; // Option to show all Manufacturers $html .= '<option value="ALLMAN0">' . $this->l('All manufacturers') . '</option>'; $manufacturers = Manufacturer::getManufacturers(false, $this->context->language->id); foreach ($manufacturers as $manufacturer) { if (!in_array('MAN' . $manufacturer['id_manufacturer'], $items)) { $html .= '<option value="MAN' . $manufacturer['id_manufacturer'] . '">' . $spacer . $manufacturer['name'] . '</option>'; } } $html .= '</optgroup>'; // BEGIN Categories $shop = new Shop((int) Shop::getContextShopID()); $html .= '<optgroup label="' . $this->l('Categories') . '">'; $html .= $this->generateCategoriesOption(Category::getNestedCategories(null, (int) $this->context->language->id, true), $items); $html .= '</optgroup>'; // BEGIN Shops if (Shop::isFeatureActive()) { $html .= '<optgroup label="' . $this->l('Shops') . '">'; $shops = Shop::getShopsCollection(); foreach ($shops as $shop) { if (!$shop->setUrl() && !$shop->getBaseURL()) { continue; } if (!in_array('SHOP' . (int) $shop->id, $items)) { $html .= '<option value="SHOP' . (int) $shop->id . '">' . $spacer . $shop->name . '</option>'; } } $html .= '</optgroup>'; } // BEGIN Products $html .= '<optgroup label="' . $this->l('Products') . '">'; $html .= '<option value="PRODUCT" style="font-style:italic">' . $spacer . $this->l('Choose product ID') . '</option>'; $html .= '</optgroup>'; // BEGIN Menu Top Links $html .= '<optgroup label="' . $this->l('Menu Top Links') . '">'; $links = MenuTopLinks::gets($this->context->language->id, null, (int) Shop::getContextShopID()); foreach ($links as $link) { if ($link['label'] == '') { $default_language = Configuration::get('PS_LANG_DEFAULT'); $link = MenuTopLinks::get($link['id_linksmenutop'], $default_language, (int) Shop::getContextShopID()); if (!in_array('LNK' . (int) $link[0]['id_linksmenutop'], $items)) { $html .= '<option value="LNK' . (int) $link[0]['id_linksmenutop'] . '">' . $spacer . $link[0]['label'] . '</option>'; } } elseif (!in_array('LNK' . (int) $link['id_linksmenutop'], $items)) { $html .= '<option value="LNK' . (int) $link['id_linksmenutop'] . '">' . $spacer . $link['label'] . '</option>'; } } $html .= '</optgroup>'; $html .= '</select>'; return $html; }
private function displayCategoriesSelect($categories, $selected) { $this->_html .= '<label>' . $this->l('Category') . '</label> <div class="margin-form"><select name="id_category"> <option value="">-- ' . $this->l('Choose') . ' --</option>'; if (version_compare(_PS_VERSION_, '1.6.0.0', '>=') && method_exists('Category', 'getNestedCategories')) { foreach (Category::getNestedCategories(Configuration::get('PS_ROOT_CATEGORY'), $this->_cookie->id_lang) as $idCategory => $categoryInformations) { if (Configuration::get('PS_ROOT_CATEGORY') != $idCategory) { $this->_html .= '<option value="' . $idCategory . '"' . ($selected == $idCategory ? ' selected="selected"' : '') . '>' . str_repeat('– ', version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? $categoryInformations['level_depth'] - 1 : $categoryInformations['level_depth']) . $categoryInformations['name'] . '</option>'; } $this->_getChildrensCategories($categoryInformations, $selected); } } else { if (version_compare(_PS_VERSION_, '1.5.0.0', '>=') && method_exists('Category', 'recurseLiteCategTree')) { $rootCategory = new Category((int) Category::getRootCategory()->id, $this->_cookie->id_lang); if (Configuration::get('PS_ROOT_CATEGORY') != $rootCategory->id) { $this->_html .= '<option value="' . $rootCategory->id . '"' . ($selected == $rootCategory->id ? ' selected="selected"' : '') . '>' . $rootCategory->name . '</option>'; } $this->_getChildrensCategories($rootCategory->recurseLiteCategTree(99999, 0, $this->_cookie->id_lang), $selected, 0); } else { $categories_bkup = $categories; $first_category = array_shift($categories_bkup); array_unshift($categories_bkup, $first_category); $first_category_final = array_shift($first_category); $this->recurseCategory($categories, $first_category_final, version_compare(_PS_VERSION_, '1.5.0.0', '>=') ? Category::getRootCategory()->id : 1, $selected); } } $this->_html .= ' </select></div>'; }
public function hookFooter($params) { $user_groups = $this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP')); $block1_id = Configuration::get('FOOTER_1_CAT_BLOCK', 0); $id_lang = (int) $this->context->language->id; if ($block1_id != 0) { $category1 = Category::getNestedCategories($block1_id, $id_lang, true, $user_groups); $category1 = $category1[$block1_id]; } else { $category1 = null; } $block2_ids = json_decode(Configuration::get('FOOTER_2_CAT_BLOCK', '[]')); if (!empty($block2_ids)) { $categories = array(); foreach ($block2_ids as $key => $id) { if ($id != 0) { if ($key == 3) { $sql_limit = 'LIMIT 0, 4'; } else { $sql_limit = ''; } $temp = Category::getNestedCategories($id, $id_lang, true, $user_groups, true, '', '', $sql_limit); $categories2[] = $temp[$id]; } } } else { $categories2 = array(); } $block3_id = Configuration::get('FOOTER_3_CAT_BLOCK', 0); if ($block3_id != 0) { $sql_limit = 'LIMIT 0, 6'; $category3 = Category::getNestedCategories($block3_id, $id_lang, true, $user_groups, true, '', '', $sql_limit); $category3 = $category3[$block3_id]; } else { $category3 = null; } $block4_id = Configuration::get('FOOTER_4_CMS_BLOCK', 0); if ($block4_id != 0) { $sql_limit = 'LIMIT 0, 10'; $category4 = new CMSCategory((int) $block4_id, (int) $id_lang); if (count($category4)) { $category['link'] = Tools::HtmlEntitiesUTF8($category4->getLink()); $category['name'] = $category4->name; $pages = $this->getCMSPages($category4->id); foreach ($pages as $page) { $cms = new CMS($page['id_cms'], (int) $id_lang); $links = $cms->getLinks((int) $id_lang, array((int) $cms->id)); $page['link'] = $links[0]['link']; $category['pages'][] = $page; } $category4 = $category; } else { $category4 = null; } } else { $category4 = null; } $this->smarty->assign('category1', $category1); $this->smarty->assign('categories2', $categories2); $this->smarty->assign('category3', $category3); $this->smarty->assign('category4', $category4); $this->smarty->assign('footer_category', new Category()); $display = $this->display(__FILE__, 'footer.tpl'); return $display; }
/** * Builds menu item * * @param array $menuItem * @param int $id_shop * @param int $id_lang * * @return array */ protected function buildCategoryTree(array $menuItem, $id_shop, $id_lang) { $id_category = (int) $menuItem['entity_id']; $category = new Category($id_category, $id_lang, $id_shop); if (!$category->active) { return false; } if ($this->context->customer->isLogged()) { $groups = $this->context->customer->getGroups(); } else { $groups = array(Configuration::get('PS_UNIDENTIFIED_GROUP')); } $treeMaxDepth = max(0, (int) $menuItem['tree_max_depth']); // @TODO How is this recursive ?? $categoryTree = Category::getNestedCategories($id_category, $id_lang, true, $groups); $subItems = array(); if (!empty($categoryTree[$id_category]['children'])) { foreach ($categoryTree[$id_category]['children'] as $categoryTreeChild) { $subItems[] = $this->buildCategoryTreeItem($categoryTreeChild, $id_shop, $id_lang, 1, $treeMaxDepth); } } $url = empty($menuItem['url']) ? $this->context->link->getCategoryLink($category) : $menuItem['url']; return array('name' => empty($menuItem['name']) ? $category->name : $menuItem['name'], 'url' => $url, 'title' => empty($menuItem['title']) ? $category->name : $menuItem['title'], 'icon' => $menuItem['icon'], 'no_follow' => $menuItem['no_follow'], 'id' => $menuItem['id_ct_top_menu_item'], 'entity_id' => 'cat-' . $id_category, 'class' => $menuItem['class'], 'type' => 'category-tree', 'sub_items' => $subItems); }
} return Cache::retrieve($cache_id); } public static function getPrestaProdChildCat($cats) { foreach ($cats as $cat) { if ($cat['id_shop'] == Context::getContext()->shop->id) { self::$prestaprds['category_' . $cat['id_category']] = $cat['name']; } if (isset($cat['children']) && !empty($cat['children'])) { self::getPrestaProdChildCat($cat['children']); } } } public static function getPrestaProdCat() { if (method_exists('Category', 'getNestedCategories')) { $cats = Category::getNestedCategories(null, (int) Context::getContext()->language->id, true); } else { $cats = self::getNestedCategories(null, (int) Context::getContext()->language->id, true);