Jump to content

Nav Links


Recommended Posts

ok i've figured this out - i'm never sure if this is the "correct" way, but it does seem to work. :idea:

 

looking at the secondary navbar (login), it seems as though the divider was using a different css class - that was the clue I needed... then it was just a case of using setClass to define the class for the child.

 

so as an example, i've modified the contact us navbar link - added a child; added a separator child & defined the css class; and then added another child...

 

cX4jn6X.png

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
   if (!is_null($primaryNavbar->getChild('Contact Us'))) {
       $primaryNavbar->getChild('Contact Us')
           ->addChild('Emergency Contacts', array(
               'label' => 'Emergency Contacts',
               'uri' => 'emergency.php',
               'order' => '100',
           ));
       $primaryNavbar->getChild('Contact Us')
           ->addChild('Divider', array(
               'order' => '200',
           ))
           ->setClass('nav-divider');            
       $primaryNavbar->getChild('Contact Us')
           ->addChild('Phone Home', array(
               'label' => 'Phone Home',
               'uri' => 'emergency.php',
               'order' => '300',
           ));            
   }
});

hopefully, you can add the divider section of the code above to suit your needs. :)

Edited by brian!
Link to comment
Share on other sites

  • 1 month later...
  • 3 months later...
Hello,

 

is there any way to edit the URL behind the Home Button of the Primary Nav?

This is how you can do it basically

 

<?php
use WHMCS\View\Menu\Item as MenuItem;

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

   if (!is_null($primaryNavbar->getChild('Home'))){
       $primaryNavbar->getChild('Home')
       ->setUri('https://www.example.com/');
   }


});

Link to comment
Share on other sites

Many thanks for this fast help....a last question today: is it also possible to rename the Home Button ?

yes, using the setLabel method as below

 

<?php
use WHMCS\View\Menu\Item as MenuItem;

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

   if (!is_null($primaryNavbar->getChild('Home'))){
       $primaryNavbar->getChild('Home')
       ->setLabel('Home Page')
       ->setUri('https://www.example.com/');
   }


});

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