dorzki Posted February 4, 2019 Share Posted February 4, 2019 Hello, I've developed a module and used the _clientarea() function to display a module page in the client area. I wanted to know how can i add a sidebar on the module client area page? Thanks in advance. 0 Quote Link to comment Share on other sites More sharing options...
hobbs Posted March 9, 2019 Share Posted March 9, 2019 Hi, i had the same question and also didn't find an accurate answer to my question. So, I did some hacking and have managed to find a solution: function addClientAreaSidebarForCustomAddonModule($vars) { $client = Menu::context('client'); if(!empty($client)){ if(isset($vars['modulelink'])){ if(strpos($vars['modulelink'],'m=customAddonModule')){ $primarySidebar = Menu::primarySidebar(); $newMenu = $primarySidebar->addChild( 'CustomAddonModule ClientArea Sidebar', array( 'name' => 'My CustomAddonModule ClientArea Sidebar', 'label' => 'My CustomAddonModule ClientArea Sidebar', 'uri' => 'index.php?m=customAddonModule', 'order' => 100, 'icon' => 'fas fa-magic', ) ); if(!is_null($primarySidebar->getChild('My CustomAddonModule ClientArea Sidebar'))){ $primarySidebar->getChild('My CustomAddonModule ClientArea Sidebar') ->addChild('Sidebar MenuItem 1') ->setLabel('Sidebar MenuItem 1') ->setUri('index.php?m=customAddonModule') ->setOrder(10); $primarySidebar->getChild('My CustomAddonModule ClientArea Sidebar') ->addChild('Sidebar MenuItem 2') ->setLabel('Sidebar MenuItem 2') ->setUri('index.php?m=customAddonModule&p=manage_2') ->setOrder(10); } $newMenu->moveToFront(); } } } } add_hook('ClientAreaPage', 1, 'addClientAreaSidebarForCustomAddonModule'); references: https://docs.whmcs.com/Working_With_Client_Area_Home_Page_Panels#Add_a_local_temperature_panel_to_the_homepage https://developers.whmcs.com/hooks-reference/client-area-interface/#clientareapage 0 Quote Link to comment Share on other sites More sharing options...
stuartoreilly Posted January 25, 2021 Share Posted January 25, 2021 The sidebars are directly available in the ClientAreaPrimaryarySidebar and ClientAreaSecondarySidebar hooks. To add a sidebar to your addon module, either add the hooks in hooks.php in your module root, or add a php file in the whmcs/includes/hooks directory and deal with your menus there (I prefer this approach - keeping menu organisation and configuration separate from the module). <?php use WHMCS\View\Menu\Item as MenuItem; if (!defined("WHMCS")) { die("This file cannot be accessed directly"); } add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar){ $module = $_GET['m']; switch ($module) { case 'customAddonModule': //Add new group to empty sidebar $panel = $secondarySidebar->addChild( 'Quick Links', [ 'label' => 'Quick Links', 'order' => 1, 'icon' => 'fas fa-shopping-cart', ] ); // Add individual links to group $panel->addChild('customAddonModule') ->setLabel('This Module') ->setIcon('fas fa-ticket') ->setUri('/index.php?m=customAddonModule') ->setClass('active') ->setOrder(1); $panel->addChild('things') ->setLabel('Buy Things') ->setIcon('fas fa-rabbit-in-headlights') ->setUri('/cart.php?gid=1') ->setOrder(2); $panel->addChild('stuff') ->setLabel('Configure Stuff') ->setIcon('fas fa-drunk-man-looking-for-keys') ->setUri('index.php?m=anotherModule') ->setOrder(3); break; case 'anotherModule' : //add another menu for another module } }); 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.