Jump to content

Nav Menus Hooks for Client Menu Sub items


Recommended Posts

Hello,

i am new with WHMCS. I am usiing WHMCS 8.1 and Theme Metro's Clean Theme.

I am trying to understand the WHMCS menu structure. 
I have already read the Docu's, but unfortunately my English and developing know how is very less.

I want add e.g. as child menus:
-  clientarea.php
-  clientarea.php?action=products
-  clientarea.php?action=invoices
-  clientarea.php?action=addfunds

and horizontal lines in to client menu (https://prnt.sc/vtki1h) for logged in clients only.

I already read:
https://docs.whmcs.com/Client_Area_Navigation_Menus_Cheatsheet
https://developers.whmcs.com/themes/navigation/
https://docs.whmcs.com/Editing_Client_Area_Menus

 

Unfortunately I didn't manage to do it. I would love if someone could post an example here.

Many thanks in advance

 

Link to comment
Share on other sites

1 hour ago, TrippleEx said:

i am new with WHMCS. I am usiing WHMCS 8.1 and Theme Metro's Clean Theme.

I hope you're not using 8.1 beta on a live site! 😲

1 hour ago, TrippleEx said:

I want add e.g. as child menus:
-  clientarea.php
-  clientarea.php?action=products
-  clientarea.php?action=invoices
-  clientarea.php?action=addfunds

those links will already exist in the menu when a user is logged in, e.g "Home" will link to clientarea, "My Services" will link to action=products and the invoices and add funds links will be in the Billing dropdown... I wouldn't necessarily see any point in adding those links for users who aren't logged in, as they'd have to login first before being redirected.

with regards to dividers (horizontal lines), hopefully the example hook in the thread below will help - you should just need to declare the divider child and setclass after the child you want to divide.

zDA9PhQ.png

Edited by brian!
Link to comment
Share on other sites

29 minutes ago, TrippleEx said:

Regarding your example, i would add the my links as child menu under "Account" (with other words, i want move them all to one menu: Account)

for the Account menu, you would need a secondary navbar hook...

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar) {
	
	$client = Menu::context('client');
	if (!is_null($client) && !is_null($secondaryNavbar->getChild('Account'))) {
		$secondaryNavbar->getChild('Account')->addChild('Divider1')->setOrder(75)->setClass('nav-divider');
		$secondaryNavbar->getChild('Account')
			->addChild('2NInvoices', array(
				'label' => Lang::trans('navinvoices'),
				'uri' => 'clientarea.php?action=invoices',
				'order' => '76',
			));
		$secondaryNavbar->getChild('Account')
			->addChild('2NAddFunds', array(
				'label' => Lang::trans('addfunds'),
				'uri' => 'clientarea.php?action=addfunds',
				'order' => '77',
			));
	}
});

EIv9w1h.pngZsOBZ6G.png

the above hook should work on virtually any version of WHMCS from the last few years - above screenshots are from v8 and v8.1b1

with regards to editing/removing navbar children with hooks, the golden rule to remember is that you *must* check that what to want to remove/edit exists before doing anything to it - if you don't, you *will* get errors.... there are many examples of removing/editing navbar child using hooks in these forums.

if it's simpler for you, you can hide navbar elements with CSS, by referencing the child's CSS ID and adding it to custom.css - e.g to remove "Email History" from that menu..

#Secondary_Navbar-Account-Email_History {display: none !important;}

i4kMEt9.png

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