Jump to content

Top horizontal menu limits


Recommended Posts

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

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

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 1 year later...

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

  • 2 years later...

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
image.png.3c8369cc13d5262f880c9a3c0cfd2c11.png

-- Just in case, hit "Clear Cache" top right button
-- Tested, Worked for me!

Hope this can help.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...