plusplushosting Posted October 22, 2015 Share Posted October 22, 2015 Anyone know what is the language variable i have to use with an IF so i can point to different url depending the language selected in WHMCS? Thanx! add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $navItem = $primaryNavbar->getChild('Contact Us'); if (is_null($navItem)) { return; } $navItem->setUri('https://www.domain.net/contact'); }); 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted October 22, 2015 Share Posted October 22, 2015 try with the SESSION variable if ($_SESSION['language']=="english") { // Set URL } else if ($_SESSION['language']=="french") { // Set Different URL } else { // Set Default URL Maybe } 0 Quote Link to comment Share on other sites More sharing options...
plusplushosting Posted October 23, 2015 Author Share Posted October 23, 2015 Thanx but is not working :-( add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { $navItem = $primaryNavbar->getChild('Contact Us'); if (is_null($navItem)) { return; } if ($_SESSION['language']=="spanish") { $navItem->setUri('https://www.domain.net/es/contacto'); } else { $navItem->setUri('https://www.domain.net/contact'); } }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 23, 2015 Share Posted October 23, 2015 (edited) try with the SESSION variable lol - I figured out three different methods to attempt this last night... but none of them would work 100% - I didn't even think of checking the session! unfortunately, as plus says, this session trick doesn't quite work... Language isn't in the session at the start. I wrote the hook below to test sentq's idea... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if ($_SESSION['Language']=="english") { $contactlink = "http://www.google.co.uk"; } elseif ($_SESSION['Language']=="french") { $contactlink = "http://www.google.fr"; } else { $contactlink = "http://www.google.com"; } if (!is_null($primaryNavbar->getChild('Contact Us'))) { $primaryNavbar->getChild('Contact Us') ->setUri($contactlink); } }); by default, it doesn't work because Language doesn't exist... so it will set the contact link to google.com however, as soon as you select a language from the menu, Language is in the session and the contact link then changes based on the language chosen. so it's nearly there - we just need some guaranteed way to get the initial value of language.. perhaps pulling it from the Smarty variable would be one way, but maybe sentq has an alternative ? Edited October 23, 2015 by brian! 0 Quote Link to comment Share on other sites More sharing options...
plusplushosting Posted October 23, 2015 Author Share Posted October 23, 2015 Thanx brian! This did the trick..at least is working 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.