Rearrange Sidebar Items

You can customize the Client Area’s sidebar navigation menus through hooks and custom modules.

For more information, see Client Area Sidebars and our Developer Documentation.

Rearrange Sidebar Items

You can change the display order of sidebar menu items using the following code example:

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) {
    $primarySidebar->getChild('My Account')
        ->getChild('Billing Information')
        ->setOrder(25); // Default menu items have orders 10, 20, 30, etc...
});

Helpers

When you do this, the following helpers are also available:

HelperDescriptionExample
moveup()Move a menu item up one position.$primaryNavbar->getChild('My Account')->getChild('Billing Information')->moveUp();
moveDown()Move a menu item down one position.$primaryNavbar->getChild('My Account')->getChild('Billing Information')->moveDown();
moveToFront()Move a menu item to the first position.$primaryNavbar->getChild('My Account')->getChild('Billing Information')->moveToFront();
moveToBack()Move a menu item to the last position.$primaryNavbar->getChild('My Account')->getChild('Billing Information')->moveToBack();

Last modified: October 29, 2024