XimixHH Posted October 8, 2017 Share Posted October 8, 2017 Hi, I use the multi brand addon in my whmcs setup, what means I have multiple brands on one whmcs installation. All these brands have a domain like http://billing.anydomain.com/. Now I would like to point the home button to http://www.anydomain.com/ where I have a static site. Thats easy to change if you have only one brand. If I change it now every brand will have this domain, so what I was trying to do is pick up the domain from the address bar and then inserting that in the Home link. I have made a php file in the /includes/hooks directory with the following code. <?php $aedit_just_domain = preg_replace("/^(.*\.)?([^.]*\..*)$/", "$2", $_SERVER['HTTP_HOST']); $aedit_homepageurl = "http://www.". $aedit_just_domain ."/"; #adding Menu Item to primaryNavbar use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { /** Rename the "Home" menu item. **/ $primaryNavbar->getChild('Home') ->setUri ($aedit_homepageurl); }); No here you see my problem ->setUri ($aedit_homepageurl); has a variable what is aparently not possible. When I try ->setUri ('http://someurl.com'); it works fine, but I cant use that as I need a variable in there. In this case the variable $aedit_homepageurl. I have tried many different things like: ->setUri ('{$aedit_homepageurl}'); ->setUri (' .$aedit_homepageurl. '); ->setUri ({$aedit_homepageurl}); ->setUri $aedit_homepageurl; All with the same failing result. Is there anyone who can help me with this issue? Thanks a lot in advance! Link to comment Share on other sites More sharing options...
brian! Posted October 9, 2017 Share Posted October 9, 2017 1 hour ago, XimixHH said: Now here you see my problem ->setUri ($aedit_homepageurl); has a variable what is apparently not possible. take a look at the following hook and see how it uses setURI to changes the navbar home link using a variable... and then adjust it for your needs. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $redirect = 'http://www.google.com'; if (!is_null($primaryNavbar->getChild('Home'))) { $primaryNavbar->getChild('Home') ->setURI($redirect); } }); Link to comment Share on other sites More sharing options...
XimixHH Posted October 9, 2017 Author Share Posted October 9, 2017 Doesnt seem to work. When I keep the $redirect static like in your example, it's fine. Soon as I make that into a variable it fails: <?php $aedit_just_domain = preg_replace("/^(.*\.)?([^.]*\..*)$/", "$2", $_SERVER['HTTP_HOST']); $aedit_homepageurl = "http://www.". $aedit_just_domain ."/"; use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $redirect = $aedit_homepageurl; if (!is_null($primaryNavbar->getChild('Home'))) { $primaryNavbar->getChild('Home') ->setURI($redirect); } }); Because I use the multibrand addon, the only thing I really want is that it picks up the url in the address field like http://billing.mydomain.com/, replace "billing." with "www." so it becomes http://www.mydomain.com, then makes the home button link there. Anyone else or maybe you again Brian! that can think of a solution? Thanks again and thanks in advance! Link to comment Share on other sites More sharing options...
XimixHH Posted October 11, 2017 Author Share Posted October 11, 2017 I had an answer on stackoverflow to this question that worked. Just wanted to post the link here so it can help others: https://stackoverflow.com/questions/46648184/whmcs-and-changing-home-link-with-variable Link to comment Share on other sites More sharing options...
brian! Posted October 11, 2017 Share Posted October 11, 2017 On 10/9/2017 at 12:26 PM, XimixHH said: Anyone else or maybe you again Brian! that can think of a solution? why are you creating variables outside of the hook ?? that second solution on Stack is what I was implying by putting $redirect inside the hook! Link to comment Share on other sites More sharing options...
Athlone Posted November 14, 2017 Share Posted November 14, 2017 How are you finding Multibrand? The good, the bad and the ugly, I'm thinking of taking the plunge. Link to comment Share on other sites More sharing options...
Recommended Posts