Rearrange Menu Items

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

For more information about customizing the Client Area’s navigation menus, see Client Area Navigation Menus and our Developer Documentation.

Rearrange Menu Items

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

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) {
    $navItem = $primaryNavbar->getChild('Support');
    if (is_null($navItem)) {
        return;
    }

    $navItem = $navItem->getChild('Announcements');
    if (is_null($navItem)) {
        return;
    }

    $navItem->setOrder(1);
});

Helpers

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

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

Last modified: June 5, 2024