Search code examples
magentohyperlinkmagento2account

How to set active menu links under 'My Account' in Magento 2 frontend Customer Section


I've got a custom module extending the customer account section. I've added a new link called 'My Uploads'. This link appears at the bottom of the My Account links sidebar. On the index page, the 'My Uploads' link is bolded and not selectable. However on my child pages none of the links are bolded or selectable. I am searching how to keep the same link functionality in my custom module (i.e. all parent and child pages show the same sidebar link as active.) _SetActiveMenu appears to only be a method accessible in admin controllers so I really don't know any way to do this. Anyone have any clues?


Solution

  • If I am not mistaken, you want to add a link in Customers "My Account" Sidebar. So, navigation.php which is available in /app/code/local/themename/customer/block/account/navigation.php controling those links. There are few function inside the file, some of them :

    public function isActive($link)  
    {
    if (empty($this->_activeLink)) {
        $this->_activeLink = $this->getAction()->getFullActionName('/');
    }
    if ($this->_completePath($link->getPath()) == $this->_activeLink) {
        return true;
    }
    return false;
    } 
    
    
    public function setActive($path)
    {
        $this->_activeLink = $this->_completePath($path);
        return $this;
    }