Jump to content
coreygun

Top horizontal menu limits

Recommended Posts

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

post-1176840-0-97421200-1475066335_thumb.png

Share this post


Link to post
Share on other sites

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.

post-1292894-0-08822200-1475115774_thumb.png

post-1292894-0-20929400-1475115790_thumb.png

post-1292894-0-30426300-1475115802_thumb.png

Edited by pause4paws (see edit history)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

post-1176840-0-69132000-1475839879_thumb.png

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

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

  • Like 1

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More