Ugyen Posted June 2, 2016 Share Posted June 2, 2016 Hi whmcs community, I would like to change my service menu link redirects to different languages for instance in english and my language. in english for all and my language to my country only as I have two services website for each language. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $navItem = $primaryNavbar->getChild('Services'); if (is_null($navItem)) { return; } $navItem = $navItem->getChild('My_Services'); if (is_null($navItem)) { return; } $navItem-> addChild('twitter-link', array( 'uri' => Lang::trans('mylink'), )) ->setAttribute("target", "_blank"); }); } ?> And changed Language in $_LANG['mylink'] = "https://mylink.com"; I want to assure myself that is this the way we can change menu link for different languages by implying whmcs hook. Looking forward hearing from you all. With Best regards, Ugyen 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted June 2, 2016 Share Posted June 2, 2016 What you need is to provide different URL based on the language selected? if that is the case then your code should look like below <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $Services = $primaryNavbar->getChild('Services'); if (is_null($Services)) { return; } $MyServices = $Services->getChild('My_Services'); if (is_null($MyServices)) { return; } $TwitterLink = $Services->addChild('twitter-link', array('label' => "Twitter Link")); $TwitterLink->setURI(Lang::trans('mylink')); $TwitterLink->setAttribute("target", "_blank"); }); ?> 0 Quote Link to comment Share on other sites More sharing options...
Ugyen Posted June 2, 2016 Author Share Posted June 2, 2016 Thank you so much for your kind consideration... My main intention here is to change a link point for OrderNewServices. I have shared my screenshot here. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $Services = $primaryNavbar->getChild('Services'); if (is_null($Services)) { return; } $OrderNewServices = $Services->getChild('Order_New_Services'); if (is_null($OrderNewServices)) { return; } $ProductLink = $Services->addChild('product-link', array('label' => "Product Link")); $ProductLink->setURI(Lang::trans('mylink')); $ProductLink->setAttribute("target", "_blank"); }); ?> Hope I followed your instruction correctly. Looking forward hearing from you. With Best regards, Ugyen 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted June 2, 2016 Share Posted June 2, 2016 and you need to use Language Override functionality to specify the URL <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $Services = $primaryNavbar->getChild('Services'); if (is_null($Services)) { return; } $OrderNewServices = $Services->getChild('Order New Services'); if (is_null($OrderNewServices)) { return; } $OrderNewServices->setURI(Lang::trans('mylink')); $OrderNewServices->setAttribute("target", "_blank"); }); ?> 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.