Jump to content

Small problem with hooks!


endfm

Recommended Posts

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?

nav.png

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.

Link to comment
Share on other sites

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. :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated