Jump to content

creating a hook for the nav bar


Recommended Posts

I am trying to create a hook for the nav bar. I am trying to add a link the parent link would be 'Reviews' with the link going to your domain.ca/reviews.php and then a child but would only be displayed if logged in and the title would be 'Submit Review' and the url link would be yourdomain.ca/submitreview.php

 

I have been playing around with this for over an hour now and cant figure this out, can someone please help.

Link to comment
Share on other sites

Create new PHP file inside /includes/hooks/ directory, with "anyname.php", put the following code inside it:

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook("ClientAreaPrimaryNavbar", 1, function (MenuItem $primaryNavbar){

   $client = Menu::context("client");

   $reviews = $primaryNavbar->addChild("Reviews")
               ->setURI("reviews.php")
               ->setLabel("Reviews")
               ->setOrder(70);

   if (!is_null($client)){

       /*
       $reviews->addChild("BrowseReviews")
               ->setURI("reviews.php")
               ->setLabel("Reviews")
               ->setOrder(1);
       */

       $reviews->addChild("AddReview")
               ->setURI("submitreview.php")
               ->setLabel("Submit Review")
               ->setOrder(2);

   }

});

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