Jump to content

Can't override Blocktopmenu function generateCategoriesMenu


wayann

Recommended Posts

if (!defined('_CAN_LOAD_FILES_'))
    exit;


class BlocktopmenuOverride extends Blocktopmenu
{
	public function generateCategoriesMenu($categories, $is_children = 0)
	{
            die( var_dump ('hello I am an override') );
	}
}

setting up this in the folder override/modules cleared the cache file class_index.php

 

it works if I strip of the parent function but then this override is pointless....

 

any hints of why it doesn't work?

 

I'm on 1.6.0.12

Edited by wayann (see edit history)
Link to comment
Share on other sites

  • 4 months later...

Hello wayann,
 
I'm trying to set an override in order to limit the subcategory levels on the menu but is not working even when is a protected funtion according to the original blocktopmenu.php
 
Is it somethig wrong?
 
if (!defined('_CAN_LOAD_FILES_'))
    exit;
 
class BlockTopMenuOverride extends BlockTopMenu
{
    protected function generateCategoriesMenu($categories, $is_children = 0)
    {
        $html = '';

        foreach ($categories as $key => $category)
        {
            if ($category['level_depth'] > 1)
            {
                $cat = new Category($category['id_category']);
                $link = Tools::HtmlEntitiesUTF8($cat->getLink());
            }
            else
                $link = $this->context->link->getPageLink('index');

            $html .= '<li'.(($this->page_name == 'category'
                && (int)Tools::getValue('id_category') == (int)$category['id_category']) ? ' class="sfHoverForce"' : '').'>';
            $html .= '<a href="'.$link.'" title="'.$category['name'].'">'.$category['name'].'</a>';

            if ($category['level depth'] < 4 && isset($category['children']) && !empty($category['children']))
            {
                $html .= '<ul>';
                $html .= $this->generateCategoriesMenu($category['children'], 1);

                if ((int)$category['level_depth'] > 1 && !$is_children)
                {
                    $files = scandir(_PS_CAT_IMG_DIR_);

                    if (count($files) > 0)
                    {
                        $html .= '<li class="category-thumbnail">';

                        foreach ($files as $file)
                            if (preg_match('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $file) === 1)
                                $html .= '<div><img src="'.$this->context->link->getMediaLink(_THEME_CAT_DIR_.$file)
                                .'" alt="'.Tools::SafeOutput($category['name']).'" title="'
                                .Tools::SafeOutput($category['name']).'" class="imgm" /></div>';
                        $html .= '</li>';
                    }
                }
                $html .= '</ul>';
            }
            $html .= '</li>';
        }
        return $html;
    }
}

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