PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, August 23, 2022

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

 August 23, 2022     account, hyperlink, magento, magento2     No comments   

Issue

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;
}


Answered By - Oğuz Çelikdemir
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing