Jump to content

error in sub menu in a main menu link


cseamiya

Recommended Posts

Hi,

i want to provide ssl services and mail services menu link in client area navigation bar, but i want to show it in sub menu of services. and in hook i submit it and it will work fine, but after that when i go to client site and logout it show Ooops... something error.

what should i do?

Link to comment
Share on other sites

1 hour ago, cseamiya said:

what should i do?

enable display errors from general settings -> other and see what the actual error is.

also, post the code (with screenshots of where it should be) and i'll tell you what's wrong with it - though even without seeing the code, I could hazard a reasonable guess at what you're doing wrong.

Link to comment
Share on other sites

3 hours ago, brian! said:

enable display errors from general settings -> other and see what the actual error is.

also, post the code (with screenshots of where it should be) and i'll tell you what's wrong with it - though even without seeing the code, I could hazard a reasonable guess at what you're doing wrong.

when i put this code in hook, it will show in client area but after click on logout button it show error, and the whole site is not opening, 

Link to comment
Share on other sites

3 minutes ago, cseamiya said:

when i put this code in hook, it will show in client area but after click on logout button it show error, and the whole site is not opening, 

then you need to post the hook code that you're using - I can't comment on code that I can't see!

Link to comment
Share on other sites

3 minutes ago, brian! said:

then you need to post the hook code that you're using - I can't comment on code that I can't see!

here is the code i use in hook:

$primaryNavbar->addChild('Dashboard')->setOrder(1)->setUri('https://www.example.com/client/clientarea.php');        //(this is use for a menu name dashboard)
    $primaryNavbar->addChild('Services')->setOrder(20);         
            $primaryNavbar->getChild('Services')->addChild('SSL')->setUri('https://www.example.com/ssl/')->setOrder(3);
            $primaryNavbar->getChild('Services')->addChild('Mail Services')->setUri('https://www.example.com/mail-services/')->setOrder(4);

 

when i put this whole code from addChild(services to setUri url link)) it will show sub menu but when i click logout button it show error.

Quote

 

 

Link to comment
Share on other sites

basically you need to check that a parent (Services) exists before you try to modify it... when the client is logged in, Services exists... when they are logged out, Services does not exist... and that will cause an error.

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	if (is_null($primaryNavbar->getChild('Dashboard'))) {
		$primaryNavbar->addChild('Dashboard')
			->setOrder(1)
			->setUri('https://www.example.com/client/clientarea.php');  
	}
	if (!is_null($primaryNavbar->getChild('Services'))) {
		$primaryNavbar->getChild('Services')
			->addChild('SSL')
			->setUri('https://www.example.com/ssl/')
			->setOrder(3);
	}
	if (!is_null($primaryNavbar->getChild('Services'))) {
		$primaryNavbar->getChild('Services')
			->addChild('Mail Services')
			->setUri('https://www.example.com/mail-services/')
			->setOrder(4);
	}
});

so the hook does 3 things..

  1. checks if "Dashboard" already exists - if it doesn't, it creates the link (though it's the same as the "Home" link - unless you've changed that).
  2. checks if the "Services" parent exists - if it does, then it adds the SSL child link to it.
  3. checks if the "Services" parent exists - if it does, then it adds the Mail Services child link to it.

s00Rx6r.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