biaf Posted May 18, 2016 Share Posted May 18, 2016 Hello, I followed your tutorial to add a sub menu but it does not work. http://docs.whmcs.com/Client_Area_Navigation_Menus_Cheatsheet I would add a link in my widget Service Details Actions link I want to add is the following Tittle: Débloquer une IP 'uri' => 'index.php?m=unblockip', What should I put in my file NavbarLinks.php ? Code: <?php $ca = new WHMCS_ClientArea(); use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $client = Menu::context('client'); // Navbar Items for Clients if (!is_null($primaryNavbar->removeChild('Affiliates'))) {} if (!is_null($primaryNavbar->removeChild('Open Ticket'))) {} // Moved custom pages in services child menu if (!is_null($primaryNavbar->getChild('Services'))) { $primaryNavbar->getChild('Services') ->addChild('Hébergement Mutualisé', array( 'uri' => 'web_hosting.php', 'order' => '50', )); /* $primaryNavbar->getChild('Services') ->addChild('Reseller Hosting', array( 'uri' => 'reseller_hosting.php', 'order' => '60', ));*/ $primaryNavbar->getChild('Services') ->addChild('Serveur Cloud', array( 'uri' => 'vps_hosting.php', 'order' => '70', )); $primaryNavbar->getChild('Services') ->addChild('Nom de domaine', array( 'uri' => 'domainchecker.php', 'order' => '71', )); /* $primaryNavbar->getChild('Services') ->addChild('Serveur Dédié', array( 'uri' => 'dedicated_servers.php', 'order' => '80', ));*/ } //Moved Affiliate links to under Billing child menu if (!is_null($primaryNavbar->getChild('Billing'))) { $primaryNavbar->getChild('Billing') ->addChild('Affiliates', array( 'label' => Lang::trans('affiliatestitle'), 'uri' => 'affiliates.php', 'order' => '70', )); } //Moved Open Ticket links to under Support child menu if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support') ->addChild('Open Ticket', array( 'label' => Lang::trans('navopenticket'), 'uri' => 'submitticket.php', 'order' => '10', )); $primaryNavbar->getChild('Support') ->addChild('Contact Us', array( 'label' => Lang::trans('contactus'), 'uri' => 'contact.php', 'order' => '70', )); } // Menu partenaires if (!is_null($primaryNavbar->addChild('partenaires'))) { $navItem = $primaryNavbar->getChild('partenaires'); if (is_null($navItem)) { return; } $navItem->setOrder(80); $navItem->setLabel(Lang::trans('Partenariat')); $primaryNavbar->getChild('partenaires') ->addChild('nospartenaires', array( 'label' => Lang::trans('Nos Partenaires'), 'uri' => 'nospartenaires.php', 'order' => '10', )); $primaryNavbar->getChild('partenaires') ->addChild('devenirpartenaire', array( 'label' => Lang::trans('Devenir Partenaire'), 'uri' => 'devenirpartenaire.php', 'order' => '30', )); $primaryNavbar->getChild('partenaires') ->addChild('bannieres', array( 'label' => Lang::trans('Nos bannières'), 'uri' => 'bannieres.php', 'order' => '40', )); } // Custom About Us menu rearrange order for clients if (!is_null($primaryNavbar->addChild('A propos'))) { $navItem = $primaryNavbar->getChild('A propos'); if (is_null($navItem)) { return; } $navItem->setOrder(40); $navItem->setUri('about_us.php'); } if (is_null($client)) { // Navbar Items for visitors if (!is_null($primaryNavbar->removeChild('Announcements'))) {} if (!is_null($primaryNavbar->removeChild('Network Status'))) {} if (!is_null($primaryNavbar->removeChild('Knowledgebase'))) {} // Custom Servers menu for logout clients if (!is_null($primaryNavbar->addChild('Services'))) { $navItem = $primaryNavbar->getChild('Services'); if (is_null($navItem)) { return; } $navItem->setOrder(20); $navItem->setLabel(Lang::trans('navservices')); $primaryNavbar->getChild('Services') ->addChild('Hébergement Mutualisé', array( 'uri' => 'web_hosting.php', 'order' => '10', )); /*$primaryNavbar->getChild('Services') ->addChild('Reseller Hosting', array( 'uri' => 'reseller_hosting.php', 'order' => '20', ));*/ $primaryNavbar->getChild('Services') ->addChild('Serveur Cloud', array( 'uri' => 'vps_hosting.php', 'order' => '30', )); $primaryNavbar->getChild('Services') ->addChild('Nom de domaine', array( 'uri' => 'domainchecker.php', 'order' => '71', )); /* $primaryNavbar->getChild('Services') ->addChild('Serveur Dédié', array( 'uri' => 'dedicated_servers.php', 'order' => '40', ));*/ } //Custom support menu if (!is_null($primaryNavbar->addChild('Support'))) { $navItem = $primaryNavbar->getChild('Support'); if (is_null($navItem)) { return; } $navItem->setOrder(20); $navItem->setLabel(Lang::trans('navsupport')); $primaryNavbar->getChild('Support') ->addChild('Tickets', array( 'label' => Lang::trans('navtickets'), 'uri' => 'supporttickets.php', 'order' => '10', )); $primaryNavbar->getChild('Support') ->addChild('Knowledgebase', array( 'label' => Lang::trans('knowledgebasetitle'), 'uri' => 'knowledgebase.php', 'order' => '20', )); $primaryNavbar->getChild('Support') ->addChild('Announcements', array( 'label' => Lang::trans('announcementstitle'), 'uri' => 'announcements.php', 'order' => '30', )); $primaryNavbar->getChild('Support') ->addChild('Network Status', array( 'label' => Lang::trans('networkstatustitle'), 'uri' => 'serverstatus.php', 'order' => '40', )); } // Inscription et Deconnexion if (!is_null($primaryNavbar->addChild('register'))) { $navItem = $primaryNavbar->getChild('register'); if (is_null($navItem)) { return; } $navItem->setOrder(90); $navItem->setLabel(Lang::trans('Inscription')); $navItem->setUri('register.php'); } if (!is_null($primaryNavbar->addChild('Login'))) { $navItem = $primaryNavbar->getChild('Login'); if (is_null($navItem)) { return; } $navItem->setOrder(90); $navItem->setLabel(Lang::trans('Connexion')); $navItem->setUri('clientarea.php'); } //Menu Partenaire if (!is_null($primaryNavbar->addChild('partenaires'))) { $navItem = $primaryNavbar->getChild('partenaires'); if (is_null($navItem)) { return; } $navItem->setOrder(80); $navItem->setLabel(Lang::trans('Partenariat')); $primaryNavbar->getChild('partenaires') ->addChild('nospartenaires', array( 'label' => Lang::trans('Nos Partenaires'), 'uri' => 'nospartenaires.php', 'order' => '10', )); $primaryNavbar->getChild('partenaires') ->addChild('devenirpartenaire', array( 'label' => Lang::trans('Devenir Partenaire'), 'uri' => 'devenirpartenaire.php', 'order' => '30', )); $primaryNavbar->getChild('partenaires') ->addChild('bannieres', array( 'label' => Lang::trans('Nos bannières'), 'uri' => 'bannieres.php', 'order' => '40', )); } // Custom About Us menu rearrange order for visitors $navItem = $primaryNavbar->getChild('About Us'); if (is_null($navItem)) { return; } $navItem->setOrder(30); } }); ?> The support told me to put use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $primaryNavbar->addChild('Débloquer une IP') ->setUri('index.php?m=unblockip') ->setOrder(70); }); But I have to put where? thanks for the help 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 18, 2016 Share Posted May 18, 2016 But I have to put where? add the file to the /includes/hooks/ directory. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted May 18, 2016 Share Posted May 18, 2016 also no need to add this line in action hook file: $ca = new WHMCS_ClientArea(); 0 Quote Link to comment Share on other sites More sharing options...
biaf Posted May 20, 2016 Author Share Posted May 20, 2016 Thank you for the help but the problem is that I want to add the link to the widget (right menu) in action on the product detail page To access must connect -> My Products and Services -> products managements then the right menu Action (I want to add a link in the menu) 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 20, 2016 Share Posted May 20, 2016 in that case, you were given the wrong advice by Support. you are referring to a sidebar and not a navmenu - the hooks work in similar ways, but you need to use a different hook for them... if you wanted to do this in a separate file in includes/hooks/, you would use the following to add an entry to that sidebar... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { if (!is_null($primarySidebar->getChild('Service Details Actions'))) { $primarySidebar->getChild('Service Details Actions') ->addChild('Débloquer une IP') ->setUri('index.php?m=unblockip') ->setOrder('30'); } }); if you wanted to use it in your existing NavBarLinks.php file, then you just need to use everything *after* the 'Use' line of code.. add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { if (!is_null($primarySidebar->getChild('Service Details Actions'))) { $primarySidebar->getChild('Service Details Actions') ->addChild('Débloquer une IP') ->setUri('index.php?m=unblockip') ->setOrder('30'); } }); you many need to change the SetOrder value depending upon where you want the link to be in the sidebar. 0 Quote Link to comment Share on other sites More sharing options...
biaf Posted May 20, 2016 Author Share Posted May 20, 2016 Thank you very much. I will test the plugins UnblockIP see if it works 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.