DennisHermannsen Posted September 10, 2016 Share Posted September 10, 2016 How would I go about using language strings in hooks? Should be simple, but I really can't wrap my head around it 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 10, 2016 Share Posted September 10, 2016 in a navbar hook, you would use it as shown in the thread below... https://forum.whmcs.com/showthread.php?117618-Hook-with-variable-from-language-file&p=475286#post475286 e.g find the entry in the language file, e.g english.php, and then use Lang::trans to output the string in the current language. searching for lang::trans in the forum should find a lot of example hooks where this technique has been used. I don't think it's mentioned in the docs, but if all you want to change us the text (label) of a default navbar child, you can often just change it using Language Overrides without the need for a hook... though if you need to add/remove a navbar child, then a hook is the way to go. 0 Quote Link to comment Share on other sites More sharing options...
DennisHermannsen Posted September 10, 2016 Author Share Posted September 10, 2016 Alrighty, thanks brian! After working a bit with it, I made it work. I had some trouble fixing this when just adding a child to the 'root' (a link in the menu), but it was fixed by creating an array after. Ended up with this: $primaryNavbar->addChild('MyItem', array('label' => Lang::trans('my_item')))->setOrder(2); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted September 10, 2016 Share Posted September 10, 2016 that looks fine... there are a few ways to do it... and when you first start with these navbar hooks, any way that doesn't cause a blank screen can be considered a success! 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.