Jump to content

Customize ClientArea


Recommended Posts

Hi Imaran,

First of all are you sure that this is the correct version you are using as this is a Release Candidate and should not be used in production.

Any way to answer your question, you would need to create a Page Hook https://docs.whmcs.com/Client_Area_Navigation_Menus_Cheatsheet gives the details of what you are trying to do.

However, here is an example on how to remove the 'Network Status' from the top menu bar:

 

<?php
if (!defined("WHMCS"))
    die("This file cannot be accessed directly");

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function(MenuItem $primaryNavbar) {
    $primaryNavbar->removeChild('Network Status');
});

This should be saved in the includes/hooks/ folder with a .php extension.

 

 

Link to comment
Share on other sites

Dear Redit,

 

Thanks for your reply. I have already removed that from WHMCS menu using below php code. Now I want to remove the same from client area of whmcs. 

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
   if (!is_null($primaryNavbar->getChild('Network Status'))) {
       $primaryNavbar->removeChild('Network Status');
   }

   if (!is_null($primaryNavbar->getChild('Announcements'))) {
       $primaryNavbar->removeChild('Announcements');
   }

});

 

Thanks,

Imran Khan.
 

Link to comment
Share on other sites

  • 2 weeks later...

Hello @Imran Khan

Sorry not been around for a few days.

However, what you have given as your code should work to remove both the Network Status and Announcements menu items.

Are you still seeing one or more of the menu items that you want removed?

As a side note and as a personal think I always prefer to have each hook item in a different file so its easier to find exactly what I'm looking for the next time around but as I said thats a personal thing and if you are happy with all your menu hooks in one file then thats what works best for you.

 

Link to comment
Share on other sites

12 minutes ago, redit said:

However, what you have given as your code should work to remove both the Network Status and Announcements menu items.

Are you still seeing one or more of the menu items that you want removed?

I suspect he's referring to the Support menu visible when a client is logged in..

WPl7zU2.png

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
    if (!is_null($primaryNavbar->getChild('Support'))) {
        $primaryNavbar->getChild('Support')
		->removeChild('Announcements')
		->removeChild('Network Status');
	}
});
15 minutes ago, redit said:

As a side note and as a personal think I always prefer to have each hook item in a different file so its easier to find exactly what I'm looking for the next time around but as I said that's a personal thing and if you are happy with all your menu hooks in one file then that's what works best for you.

as you say, there's no right or wrong on that - but having each hook in a separate file could cause issues if they're badly coded and sending conflicting instructions... but if they're not doing that, then there's no problem! 🙂

Link to comment
Share on other sites

Hi @brian!

Well spotted sir.

I only had a very quick look at the top menu (primaryNavbar) and didn't think of drilling down any further.

One of the main reasons that I also like everything in separate files is I know exactly what I break when I'm playing I don't have a 300 line file to try and work out where I'm missing a curly bracket or I've missed a semi colon.

Again personal thing and I do try not to break stuff (honest guv) 😉

 

Link to comment
Share on other sites

36 minutes ago, redit said:

One of the main reasons that I also like everything in separate files is I know exactly what I break when I'm playing I don't have a 300 line file to try and work out where I'm missing a curly bracket or I've missed a semi colon.

lol - no i'm certainly not a fan of users putting all their hooks in the one file... fine when it works, can be a pain when they fail and you have to go digging for the cause. 🙄

40 minutes ago, redit said:

Again personal thing and I do try not to break stuff (honest guv) 😉

oh we've all coded hooks that break things (me especially included!)... I mean if I had two hooks, one that removed the support announcements child, and then the above hook ran after it, I think it would cause an error (because the second hook would be trying to remove a child already removed by the first hook)... so my hook should really check if the child exists, but I was being lazy and just posting a quick solution that would work in most cases (and certainly if all the navbar hooks were in the same file).

btw - i've got 637 separate (disabled) hooks in my v7.7 dev hooks folder - so i'm in no position to throw stones at someone suggesting the hooks should be in separate files. 🙂

Link to comment
Share on other sites

33 minutes ago, brian! said:

btw - i've got 637 separate (disabled) hooks in my v7.7 dev hooks folder

Well well, no one stand with you... I have about 10 hooks and sometimes afraid if lot of hooks could not be good for WHMCS, but I changed my mind. For all posts I have you with hooks you create, I guess also you are good in WHMCS hooks for customization, I temped to say you could use your skill to offer service for users who want to have their WHMCS with small customization, with just using hooks and some css...there is modules templates that can do that...I have tried some, but I guess would be fine to have some hooks and custom css, so customization will work easily without module setup. I know you are happy to help other time by time with your hooks, but I am saying if a user says, I need this, this this, that, change that, that...should be a service offer. 

Link to comment
Share on other sites

2 hours ago, zitu4life said:

I have about 10 hooks and sometimes afraid if lot of hooks could not be good for WHMCS, but I changed my mind.

I should add that I wouldn't have 600+ hooks (even disabled) on a production server...  it's just one of my many hook archives. 🗃️

2 hours ago, zitu4life said:

For all posts I have you with hooks you create, I guess also you are good in WHMCS hooks for customization, I temped to say you could use your skill to offer service for users who want to have their WHMCS with small customization, with just using hooks and some css..

I already do a lot of paid customisation work... my door is always open. 🙂

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