Jump to content

navbar getChild, check if exists


mitch2k

Recommended Posts

Hi,

 

I'm trying to change the destinations for the network status links using hooks. I look trough the documentation (http://docs.whmcs.com/Client_Area_Navigation_Menus_Cheatsheet#Changing_where_a_Menu_Item_Points_To)

 

I can change the link using this:

 

    $primaryNavbar->getChild('Network Status')       
     ->setUri('http://mylink.com');

 

However, when the client is logged in, Network Status is no longer a top item, but a child of Support, so I should use:

 

         $primaryNavbar->getChild('Support')
      ->getChild('Network Status')
      ->setUri('http://www.mylink.com');

 

But if I use one of the 2, the other one gives a blank page. So if I use the first piece of code, I get a blank page when the client logs in (because $primaryNavbar->getChild('Network Status') is invalid). I could catch this of with an if statement to check if the client is logged in. But, if I want to also change the secondary navbar link, I have to use:

 

  $secondaryNavbar->getChild('Support')
      ->getChild('Network Status')
->setUri('http://www.mylink.com');

 

I could also work around this with double if statement (logged in + page is a page where the secondary navbar is shown), but this seems a bit inefficient. Is there a way to check if check if the child exists? Something like:

 

if ($secondaryNavbar->getChild('Network Status') = true) {
 $secondaryNavbar->getChild('Network Status')       
->setUri('http://www.mylink.com');

}

 

Or is there a way that the statement is just ignored if the specified child does not exist?

 

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