cseamiya Posted December 4, 2018 Share Posted December 4, 2018 Hi, i want to provide ssl services and mail services menu link in client area navigation bar, but i want to show it in sub menu of services. and in hook i submit it and it will work fine, but after that when i go to client site and logout it show Ooops... something error. what should i do? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 4, 2018 Share Posted December 4, 2018 1 hour ago, cseamiya said: what should i do? enable display errors from general settings -> other and see what the actual error is. also, post the code (with screenshots of where it should be) and i'll tell you what's wrong with it - though even without seeing the code, I could hazard a reasonable guess at what you're doing wrong. 0 Quote Link to comment Share on other sites More sharing options...
cseamiya Posted December 4, 2018 Author Share Posted December 4, 2018 3 hours ago, brian! said: enable display errors from general settings -> other and see what the actual error is. also, post the code (with screenshots of where it should be) and i'll tell you what's wrong with it - though even without seeing the code, I could hazard a reasonable guess at what you're doing wrong. when i put this code in hook, it will show in client area but after click on logout button it show error, and the whole site is not opening, 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 4, 2018 Share Posted December 4, 2018 3 minutes ago, cseamiya said: when i put this code in hook, it will show in client area but after click on logout button it show error, and the whole site is not opening, then you need to post the hook code that you're using - I can't comment on code that I can't see! 0 Quote Link to comment Share on other sites More sharing options...
cseamiya Posted December 4, 2018 Author Share Posted December 4, 2018 3 minutes ago, brian! said: then you need to post the hook code that you're using - I can't comment on code that I can't see! here is the code i use in hook: $primaryNavbar->addChild('Dashboard')->setOrder(1)->setUri('https://www.example.com/client/clientarea.php'); //(this is use for a menu name dashboard) $primaryNavbar->addChild('Services')->setOrder(20); $primaryNavbar->getChild('Services')->addChild('SSL')->setUri('https://www.example.com/ssl/')->setOrder(3); $primaryNavbar->getChild('Services')->addChild('Mail Services')->setUri('https://www.example.com/mail-services/')->setOrder(4); when i put this whole code from addChild(services to setUri url link)) it will show sub menu but when i click logout button it show error. Quote 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 4, 2018 Share Posted December 4, 2018 basically you need to check that a parent (Services) exists before you try to modify it... when the client is logged in, Services exists... when they are logged out, Services does not exist... and that will cause an error. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (is_null($primaryNavbar->getChild('Dashboard'))) { $primaryNavbar->addChild('Dashboard') ->setOrder(1) ->setUri('https://www.example.com/client/clientarea.php'); } if (!is_null($primaryNavbar->getChild('Services'))) { $primaryNavbar->getChild('Services') ->addChild('SSL') ->setUri('https://www.example.com/ssl/') ->setOrder(3); } if (!is_null($primaryNavbar->getChild('Services'))) { $primaryNavbar->getChild('Services') ->addChild('Mail Services') ->setUri('https://www.example.com/mail-services/') ->setOrder(4); } }); so the hook does 3 things.. checks if "Dashboard" already exists - if it doesn't, it creates the link (though it's the same as the "Home" link - unless you've changed that). checks if the "Services" parent exists - if it does, then it adds the SSL child link to it. checks if the "Services" parent exists - if it does, then it adds the Mail Services child link to it. 0 Quote Link to comment Share on other sites More sharing options...
cseamiya Posted December 5, 2018 Author Share Posted December 5, 2018 Thanks Man 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.