Jump to content

Recommended Posts

I moved my installation to a sub-directory with it own sub-name now.

I need to change the "Home" URL from the default /index.php to https://starbursthsoting.com

Looked at: https://developers.whmcs.com/themes/navigation/
But am confused, on what to call the file and where to save it.

If someone could double check, I think I have it correct below:

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

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

    $navItem->setUri('https://starbursthosting.com');

});

Edited by StarburstHosting

Share this post


Link to post
Share on other sites

Setup > General Settings > General. Change Domain and WHMCS System URL accordingly.

Share this post


Link to post
Share on other sites
1 minute ago, Kian said:

Setup > General Settings > General. Change Domain and WHMCS System URL accordingly.

I read the question more as he wants to redirect the home button to the parent site without the included index.php - changing the system URL from the existing subdomain URL where WHMCS is now hosted wouldn't do that and would probably stop WHMCS from working.

4 hours ago, StarburstHosting said:

But am confused, on what to call the file and where to save it.

it needs to be a .php file in the /includes/hooks directory - you could call it "navbar_home.php" and then paste the above code into it and save.

4 hours ago, StarburstHosting said:

If someone could double check, I think I have it correct below:

it's not the way I would do it, but it would work.

one thing worth mentioning is that when a user is logged in, that "home" button in the portal would redirect to clientarea.php (e.g the client area home page) - but with this hook, everyone (logged in or not) will have this button redirecting to the main home page.

that may or may not be a good thing for your situation (though might leave the user no obvious way to get to their portal home), so you might have to consider only redirecting the home button to your domain if the client is not logged in.

Share this post


Link to post
Share on other sites

Thanks Brian,

How would I do it just or non-clients, like you mentioned in the last paragraph?

Edited by StarburstHosting

Share this post


Link to post
Share on other sites

Tried the below, and had placed in /includes/hooks
But didn't work either.

<?php

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

    $navItem->setUri('https://starbursthosting.com');

});

Edited by StarburstHosting

Share this post


Link to post
Share on other sites
14 minutes ago, StarburstHosting said:

How would I do it just or non-clients, like you mentioned in the last paragraph?

the way I would do it is...

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	$client = Menu::context('client');
	if (is_null($client) && !is_null($primaryNavbar->getChild('Home'))) {
		$primaryNavbar->getChild('Home')->setURI('https://starbursthosting.com');
	}
});

Share this post


Link to post
Share on other sites
22 minutes ago, brian! said:

the way I would do it is...


<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	$client = Menu::context('client');
	if (is_null($client) && !is_null($primaryNavbar->getChild('Home'))) {
		$primaryNavbar->getChild('Home')->setURI('https://starbursthosting.com');
	}
});

Thank You very much for your help.

Just uploaded and is working. 🙂

Share this post


Link to post
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