rvr Posted October 16, 2018 Share Posted October 16, 2018 Hi! I've tried this a dozen of times the last week, to no avail. I am following the WHMCS docs step by step, doesn't seem to work when trying to add anitem to the secondary sidebar. Strange thing is 😀 I can remove items. This works for removing items: add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { $client = Menu::context('client'); if (!is_null($client)) { if (!is_null($secondarySidebar->getChild('Support'))) { $secondarySidebar->getChild('Support') ->removeChild('Announcements') ->removeChild('Knowledgebase') ->removeChild('Network Status'); } } }); But when I add this: add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) { if (!is_null($secondarySidebar->getChild('Support'))) { $secondarySidebar->getChild('Support') ->addChild('Mailing List Subscription Prefs') ->setLabel('Subscription Preferences') ->setUri('subscriptionprefs.php') ->setOrder(100); } }); This doesn't add any item. (There are no PHP error messages.) After trying a few days I still didn't get it to work. Any info on why this is happening is more than welcome! Thanks! Best regards, Robert 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 17, 2018 Share Posted October 17, 2018 Hi Robert, On 16/10/2018 at 11:14, rvr said: I've tried this a dozen of times the last week, to no avail. I am following the WHMCS docs step by step, doesn't seem to work when trying to add anitem to the secondary sidebar. that assumes the docs are completely accurate on this! 😛 On 16/10/2018 at 11:14, rvr said: After trying a few days I still didn't get it to work. Any info on why this is happening is more than welcome! I can't see anything obviously wrong with the code - the PHP/use are missing, but I assume that's just for copy/paste convenience.... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) { if (!is_null($secondarySidebar->getChild('Support'))) { $secondarySidebar->getChild('Support') ->addChild('Mailing List Subscription Prefs') ->setLabel('Subscription Preferences') ->setIcon('fas fa-clipboard-list fa-fw') ->setUri('subscriptionprefs.php') ->setOrder(100); } }); for visible symmetry, i've added an icon to the child, but the above hook code works for me (it's virtually the same as yours)... 0 Quote Link to comment Share on other sites More sharing options...
rvr Posted October 19, 2018 Author Share Posted October 19, 2018 Hi Brian, Because I've tried so many things, I think I got confused at some point 😁 I did remove items from the support section in the secondary sidebar. But.... was it on the same page that I was trying to add to the the support section in the secondary sidebar. Maybe support was non existing on the page were I was trying to add to it. Thanks for thinking with me. Now I was sure I was doing it the right way. And.... I've found the solution to what I wanted. Simply adding my item to the Actions-menu did the trick. Thanks! Best regards, Robert 0 Quote Link to comment Share on other sites More sharing options...
Quard Posted September 2, 2020 Share Posted September 2, 2020 Hello, i am trying to develop whmcs but getting active class issue. It's act as active always. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function($primarySidebar) { $newMenu->addChild( 'contacts', array( 'name' => 'My Contacts', 'label' => Lang::trans('managecontacts'), 'uri' => 'mcontacts/', 'order' => 4, ) )->setClass(( ! isset($_GET['modop']) ? 'active' : '')); } Does below code still working or some changes are made on new version? ->setClass(( ! isset($_GET['modop']) ? 'active' : '')) 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.