Jump to content

Using language string in hook that changes the navbar


DennisHermannsen

Recommended Posts

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.

Link to comment
Share on other sites

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);

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