tarmouti Posted May 10, 2015 Share Posted May 10, 2015 Hi! I'd like to ask you about creating my own drop down menu with links - without hard-coding it into module files. My store has got only 4-5 products and there's no point in creating subcategory for each of them. The problem is that I can't create menu like: Products (drop down menu): Product 1 - Direct link to the product (not (sub)category) ... Product X - Direct link to the product (not (sub)category) I know that I can hook the links separately without drop-down menu, but it's waste of space. Thank you in advance. Link to comment Share on other sites More sharing options...
PascalVG Posted May 10, 2015 Share Posted May 10, 2015 Well, somewhat quick and dirty, you could do this: Edit file modules/blocktopmenu/blocktopmenu.php (Make backup!!) Go to function: private function makeMenu() Add the red code: (Sample code from PS 1.6.0.14) private function makeMenu() { $menu_items = $this->getMenuItems(); $id_lang = (int)$this->context->language->id; $id_shop = (int)Shop::getContextShopID(); $post_prd_string = '</ul></a></li>'; // string to close product submenu after last product. $last_item_was_prd = false; // Check if need to create submenu or main menu foreach ($menu_items as $item) { if (!$item) continue; preg_match($this->pattern, $item, $value); $id = (int)substr($item, strlen($value[1]), strlen($item)); if ($last_item_was_prd && substr($item, 0, strlen($value[1])) !='PRD') { // last product? $this->_menu .= $post_prd_string; // close submenu $last_item_was_prd = false; } switch (substr($item, 0, strlen($value[1]))) { case 'CAT': $this->_menu .= $this->generateCategoriesMenu(Category::getNestedCategories($id, $id_lang, true, $this->user_groups)); break; case 'PRD': if (!$last_item_was_prd) // first product? Add main menu item $this->_menu .= '<li><a href ="#" class="">'.$this->l('Products'). '<ul class="prd_submenu">'.PHP_EOL; $last_item_was_prd = true; $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': Result: If you add some products to the top hor. menu, like this: The top menu will look like this: products are grouped in submenu products: and the second group as well, in a new submenu: Hope this helps. If you need some small changes, let me know. pascal. 1 Link to comment Share on other sites More sharing options...
tarmouti Posted May 10, 2015 Author Share Posted May 10, 2015 Dear Pascal! Thank you a lot for your reply. I really appreciate your help. It redirects directly to the product page. Is there a chance that future releases of this module will contain this option as built-in? Link to comment Share on other sites More sharing options...
PascalVG Posted May 11, 2015 Share Posted May 11, 2015 The module is a standard Prestashop module. I'm a moderator at the forum (think 'volunteer'), not directly connected to the Prestashop team. You can request features on their site :-) Cheers, Pascal Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now