Jump to content

Helpertreecategory Does Not Load Child Categories When A Category Is Expanded


Recommended Posts

Hi there.

 

I am developing a AdminController for a module, and I need to add the tree for category filtering. I am using the code

            $tree = new HelperTreeCategories('associated-categories-tree', $this->l('Filter by category'));
            $tree->setAttribute('is_category_filter', (bool) $this->id_current_category)
                ->setInputName('id-category')
                ->setAttribute('is_category_filter', isset($_GET["id_category"]))
                ->setAttribute('base_url', preg_replace('#&id_category=[0-9]*#', '', self::$currentIndex) . '&token=' . $this->token);

            if (isset($_GET["id_category"]))
            {
                $tree->setSelectedCategories(array($_GET["id_category"]));
            }
            else
            {
                $tree->setSelectedCategories(array(1));
            }

            $this->context->smarty->assign(
                array(                    
                    "tree_view"  => $tree->render()
                )
            );

The tree is generated correctly, with the root category displayed. When the root category is expanded, I see its subcategories. But when these subcategories are expanded, no other categories are displayed. 

 

post-769108-0-82728300-1455550966_thumb.png

 

I noticed in the AdminProducts controller that when a category is selected and the tree is expanded, a request is triggered in order to load the subcategories.

 

post-769108-0-19895700-1455552036_thumb.png

 

But this is not happening in my controller. When a category is selected, the tree is expanded, but no ajax requests are performed. Am I missing something for this helper to work properly? Some javascript that may be missing, or maybe some html class that must be used in the tree container div?

Link to comment
Share on other sites

  • 2 weeks later...

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