endfm Posted March 30, 2016 Share Posted March 30, 2016 Hello, A few questions, I'm having a small issue with hooks. I've made this to remove the top-nav from the non client page using this code below, <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Network Status'))) { $primaryNavbar->removeChild('Network Status'); } if (!is_null($primaryNavbar->getChild('Knowledgebase'))) { $primaryNavbar->removeChild('Knowledgebase'); } if (!is_null($primaryNavbar->getChild('Home'))) { $primaryNavbar->removeChild('Home'); } if (!is_null($primaryNavbar->getChild('Account'))) { $primaryNavbar->removeChild('Account'); } if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support')->removeChild('Announcements'); } }); Everything works until this code, if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support')->removeChild('Announcements'); } & if (!is_null($primaryNavbar->getChild('Account'))) { $primaryNavbar->removeChild('Account'); } Announcements does not want to remove itself at all for some reason. Any-one have any ideas? For my second question I've got the blue nav in question totally accessible to clients at this time, which is quite different to the other pages on the website. Can I use this piece of code to remove the blue navbar totally and replace it with a picture accessible to "guests" not logged in but if a client logs in the blue nav will return? ie, {if $loggedin} else - if? {if $loggedin} <section id="main-menu"> <nav id="nav" class="navbar navbar-default navbar-main" role="navigation"> <div class="container"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">Toggle navigation</span> </button> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> {include file="$template/includes/navbar.tpl" navbar=$primaryNavbar} </ul> <ul class="nav navbar-nav navbar-right"> {include file="$template/includes/navbar.tpl" navbar=$secondaryNavbar} </ul> </div> </div> </nav> </section> {else} show some kind of picture{/if} Thank-you, apologies if this is long winded however I'm at a dead-end. /end. 0 Quote Link to comment Share on other sites More sharing options...
endfm Posted March 30, 2016 Author Share Posted March 30, 2016 Update, I actually got it all working finally. However my 2nd question still remains in regards to hiding the whmcs nav and replacing it with a picture until an actual client has entered the secure area. cheers 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 30, 2016 Share Posted March 30, 2016 Announcements does not want to remove itself at all for some reason. Any-one have any ideas? the Announcements link is called "Announcements" and isn't a child of Support - and the "Account" dropdown is a secondary navbar and not a primary one... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Network Status'))) { $primaryNavbar->removeChild('Network Status'); } if (!is_null($primaryNavbar->getChild('Knowledgebase'))) { $primaryNavbar->removeChild('Knowledgebase'); } if (!is_null($primaryNavbar->getChild('Home'))) { $primaryNavbar->removeChild('Home'); } if (!is_null($primaryNavbar->getChild('Announcements'))) { $primaryNavbar->removeChild('Announcements'); } }); add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar) { if (!is_null($secondaryNavbar->getChild('Account'))) { $secondaryNavbar->removeChild('Account'); } }); and yes to the second question. 0 Quote Link to comment Share on other sites More sharing options...
endfm Posted March 31, 2016 Author Share Posted March 31, 2016 the Announcements link is called "Announcements" and isn't a child of Support - and the "Account" dropdown is a secondary navbar and not a primary one... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Network Status'))) { $primaryNavbar->removeChild('Network Status'); } if (!is_null($primaryNavbar->getChild('Knowledgebase'))) { $primaryNavbar->removeChild('Knowledgebase'); } if (!is_null($primaryNavbar->getChild('Home'))) { $primaryNavbar->removeChild('Home'); } if (!is_null($primaryNavbar->getChild('Announcements'))) { $primaryNavbar->removeChild('Announcements'); } }); add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar) { if (!is_null($secondaryNavbar->getChild('Account'))) { $secondaryNavbar->removeChild('Account'); } }); and yes to the second question. Thanks Brian, for your help - urg I'm not to sure how I over-looked that 2nd nav however I guess it can be easily done. Just updated whmcs also, looks good especially the ticket system a lot easier especially when you're dealing with 15+ support tickets a day. also to 2nd, question, done! thanks 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.