Jump to content

Create Menu link for multiple languages from clientarea


Ugyen

Recommended Posts

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

Link to comment
Share on other sites

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

});
?>

Link to comment
Share on other sites

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

order new services.png

Link to comment
Share on other sites

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

}); 
?>

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