Jump to content

Is there a hook to remove or change the home link in the menu?


Go to solution Solved by Evolve Web Hosting,

Recommended Posts

  • Solution

@Web Host Pro You can change the name by using a language override file. In the /lang/ folder, create a new folder called /overrides/ and copy the language file you wish to edit (ie. english.php) and then make your language changes to that file.

To get you started w/ a hook. I think ('Home') is the correct value but I did not look in developer tools to confirm. $navItem->setAttribute('target', '_blank'); is only needed if you want to open the link in a new tab / window. Otherwise, comment it out or remove it.

<?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://www.yourdomain.com/page.html');
    $navItem->setAttribute('target', '_blank');
});

 

Link to comment
Share on other sites

6 hours ago, Evolve Web Hosting said:

@Web Host Pro You can change the name by using a language override file. In the /lang/ folder, create a new folder called /overrides/ and copy the language file you wish to edit (ie. english.php) and then make your language changes to that file.

To get you started w/ a hook. I think ('Home') is the correct value but I did not look in developer tools to confirm. $navItem->setAttribute('target', '_blank'); is only needed if you want to open the link in a new tab / window. Otherwise, comment it out or remove it.

<?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://www.yourdomain.com/page.html');
    $navItem->setAttribute('target', '_blank');
});

 

Dang! That worked perfect. Thanks!

Link to comment
Share on other sites

  • 3 weeks later...

Ho to remove Home only if customer is not logged in ?

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)

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

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