coreygun Posted September 28, 2016 Share Posted September 28, 2016 Hi, is there any way to limit the top horizontal menu to the first 1 or two category levels? We have about 20 of those, but at the moment as standard it shows the 3rd level too, which is about 200 categories and therefore fills the screen! Thanks Link to comment Share on other sites More sharing options...
pause4paws Posted September 29, 2016 Share Posted September 29, 2016 (edited) In admin search for blockcategories. Click the link to the Categories Block module (at the top). Click the front office features categories block. Configure and save. Add that page to "quick access" to get back to it easily. Edited September 29, 2016 by pause4paws (see edit history) Link to comment Share on other sites More sharing options...
coreygun Posted October 6, 2016 Author Share Posted October 6, 2016 In admin search for blockcategories. Click the link to the Categories Block module (at the top). Click the front office features categories block. Configure and save. Add that page to "quick access" to get back to it easily. I'm sure I tried that before, but the prestashop login (/admin1234) link isnt working at the moment... Will try again soon... Link to comment Share on other sites More sharing options...
NemoPS Posted October 7, 2016 Share Posted October 7, 2016 Here is a tut I wrote: http://nemops.com/prestashop-top-menu-limit-subcategories/#.V_d5quD5iUkhope you find it useful Link to comment Share on other sites More sharing options...
coreygun Posted October 7, 2016 Author Share Posted October 7, 2016 In admin search for blockcategories. Click the link to the Categories Block module (at the top). Click the front office features categories block. Configure and save. Add that page to "quick access" to get back to it easily. Even setting it to 1 doesnt change it... Link to comment Share on other sites More sharing options...
NemoPS Posted October 8, 2016 Share Posted October 8, 2016 That's for the category block, not for the top menu Link to comment Share on other sites More sharing options...
pause4paws Posted October 11, 2016 Share Posted October 11, 2016 (edited) Sorry, NemoPS Edited October 11, 2016 by pause4paws (see edit history) Link to comment Share on other sites More sharing options...
coreygun Posted October 20, 2016 Author Share Posted October 20, 2016 That's for the category block, not for the top menu Yep, so any way of doing it for the top menu, that you know of? Link to comment Share on other sites More sharing options...
pause4paws Posted October 20, 2016 Share Posted October 20, 2016 This is a tutorial video by NemoPS Limiting subcategories in the Prestashop Top Menu I hope it's what you're looking for. I hope I'm right this time, Nemo Link to comment Share on other sites More sharing options...
NemoPS Posted October 21, 2016 Share Posted October 21, 2016 Coreygun,I posted my tut a few messages above, and pause4paws also directly linked the video. You should be able to get it that way 1 Link to comment Share on other sites More sharing options...
coreygun Posted November 28, 2016 Author Share Posted November 28, 2016 Coreygun, I posted my tut a few messages above, and pause4paws also directly linked the video. You should be able to get it that way Bit late, but this is sorted now, using your tutorial. Thank you NemoPS! Link to comment Share on other sites More sharing options...
[email protected] Posted July 26, 2018 Share Posted July 26, 2018 For 1.7 do you have a solution to limit subcategories in top menu? Thank you Link to comment Share on other sites More sharing options...
NemoPS Posted July 30, 2018 Share Posted July 30, 2018 See if you can locate the code mentioned in the tutorial, it might be the same. The top menu has a different name but the code should be basically unchanged. Look for ps_mainmenu Link to comment Share on other sites More sharing options...
[email protected] Posted July 30, 2018 Share Posted July 30, 2018 I have looked in ps_mainmenubut I saw that only first line is unchanged the rest looks totally different. which part should I modify? protected function generateCategoriesMenu($categories, $is_children = 0) { $nodes = []; foreach ($categories as $key => $category) { $node = $this->makeNode([]); if ($category['level_depth'] > 1) { $cat = new Category($category['id_category']); $link = $cat->getLink(); } else { $link = $this->context->link->getPageLink('index'); } $node['url'] = $link; $node['type'] = 'category'; $node['page_identifier'] = 'category-' . $category['id_category']; /* Whenever a category is not active we shouldnt display it to customer */ if ((bool)$category['active'] === false) { continue; } $current = $this->page_name == 'category' && (int)Tools::getValue('id_category') == (int)$category['id_category']; $node['current'] = $current; $node['label'] = $category['name']; $node['image_urls'] = []; if (isset($category['children']) && !empty($category['children'])) { $node['children'] = $this->generateCategoriesMenu($category['children'], 1); $files = scandir(_PS_CAT_IMG_DIR_); if (count(preg_grep('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $files)) > 0) { foreach ($files as $file) { if (preg_match('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $file) === 1) { $image_url = $this->context->link->getMediaLink(_THEME_CAT_DIR_.$file); $node['image_urls'][] = $image_url; } } } } $nodes[] = $node; } return $nodes; } Thank you Link to comment Share on other sites More sharing options...
PrestAlec Posted November 16, 2020 Share Posted November 16, 2020 Hello! I had the same problem, in the Top Menu I needed to limit the Categories detail level to 1. I'm no expert coder at all, so please be kind... may be I performed major surgery instead being a bit more gentle 🙃 -- PS ver 1.7.6.8 -- File modules/ps_mainmenu/ps_mainmenu.php -- Line 715 protected function "generateCategoriesMenu" -- Disabled (commented) lines 746 to 761 as follows /*if (isset($category['children']) && !empty($category['children'])) { $node['children'] = $this->generateCategoriesMenu($category['children'], 1); if ($this->imageFiles === null) { $this->imageFiles = scandir(_PS_CAT_IMG_DIR_); } if (count(preg_grep('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $this->imageFiles)) > 0) { foreach ($this->imageFiles as $file) { if (preg_match('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $file) === 1) { $image_url = $this->context->link->getMediaLink(_THEME_CAT_DIR_.$file); $node['image_urls'][] = $image_url; } } } }*/ -- Advanced Parameters, Performance, Smarty -> Save -- Just in case, hit "Clear Cache" top right button -- Tested, Worked for me! Hope this can help. 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