Jump to content

Move "Accounts" on Homepage


Netguy

Recommended Posts

Quote

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

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
    $client = Menu::context('client');
    // remove Network Status menu
    if (!is_null($primaryNavbar->getChild('Network Status'))) {
        $primaryNavbar->removeChild('Network Status');
    }
    // remove Announcements menu
    if (!is_null($primaryNavbar->getChild('Announcements'))) {
        $primaryNavbar->removeChild('Announcements');
    }
    
    
    // remove Knowledgebase menu
    if (!is_null($primaryNavbar->getChild('Knowledgebase'))) {
        $primaryNavbar->removeChild('Knowledgebase');
    }
    //remove Store menu
    if (!is_null($primaryNavbar->getChild('Store'))) {
        $primaryNavbar->removeChild('Store');
    }
    //Add Site builder when not logged in
    if (!($client)) {
     $primaryNavbar->addChild('Site Builder')
        ->setUri('https://nasm.site/whmcs/cart.php?gid=2')
        ->setOrder(10); 
    }
    
    
    // only if logged in
    if (($client)) {
        $primaryNavbar->addChild('Billing')
            ->setUri('https://nasm.site/whmcs/clientarea.php?action=invoices')
            ->setOrder(2);
    }
    
    //Add Services Button - this also overrides the default Services Button with the drop down
     if (($client)) {
        $primaryNavbar->addChild('Services')
            ->setUri('https://nasm.site/whmcs/clientarea.php?action=services')
            ->setOrder(3);
    }
    if (($client)) {
    if (!is_null($primaryNavbar->getChild('Support'))) {
        $primaryNavbar->removeChild('Support');
    }
    }
    


});
 

This is my hook file currently and I've tried moving the account tab on my homepage to the last using setOrder but I'm failing to do so. Any ideas?

This is how the navbar looks like currently. I want to show the "Account" button after Contact Us. 

image.png.1d7a528ea2031a66c2d62ed0fe0f9837.png

Link to comment
Share on other sites

16 hours ago, Netguy said:

This is my hook file currently and I've tried moving the account tab on my homepage to the last using setOrder but I'm failing to do so. Any ideas?

usually, the visible navbar contains two separate navbars - primary (the one you're modifying in the above hook) and secondary (which usually contains "Account")...

with Six, and most custom templates, primary is shown on the left; secondary on the right... i'm tempted to think yours is reversed and it's shown secondary first (Account) and primary after that...

if that's the case, there is little that can be done with a hook - unless you just wanted to delete Account from the secondary navbar and manually add it to the primary navbar - if you did that, then you could move it to the right with setOrder.

otherwise, the order in which the two sidebars are shown is possibly defined in the header template - possibly you could swap their order around in there if Account really is still using a secondary navbar  - but i'd really have to see the site to know if Account is a secondary navbar or not.

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