Jump to content

How to change header menu link in WHMCS templates?


dnhgeeks

Recommended Posts

I have integrated WHMCS in dnhgeeks.com

 

Please visit this page dnhgeeks.com/customers and see the header menu links for Announcements and Knowledgebase are broken and produce 404 error.

 

I have viewed the template header.tpl file but it is smarty code and I cannot run php inside smarty templates.

 

How to change the url of header menu links of WHMCS in a template?

 

Where is the php code for generating the menu code in smarty ?

 

Thanks

Link to comment
Share on other sites

I have integrated WHMCS in dnhgeeks.com

 

Please visit this page dnhgeeks.com/customers and see the header menu links for Announcements and Knowledgebase are broken and produce 404 error.

 

I have viewed the template header.tpl file but it is smarty code and I cannot run php inside smarty templates.

 

How to change the url of header menu links of WHMCS in a template?

 

Where is the php code for generating the menu code in smarty ?

how did you modify those two links in the menu? are they hard-coded links in a template or did you use a hook ??

 

with v6, modifications to the menu are made via action hooks...

 

http://docs.whmcs.com/Editing_Client_Area_Menus

 

as long as you haven't tried to modify the menu in a template or an existing hook, you should be able to correct the links using an action hook..

 

so create a file in /includes/hooks/ and call it 'dnhgeekmenu.php' and add the following code to it...

 

<?php
use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
   if (!is_null($primaryNavbar->getChild('Announcements'))) {
       $primaryNavbar->getChild('Announcements')
                   ->setURI('http://dnhgeeks.com/customers/?ccce=announcements');
   }
   if (!is_null($primaryNavbar->getChild('Knowledgebase'))) {
       $primaryNavbar->getChild('Knowledgebase')
                   ->setURI('http://dnhgeeks.com/customers/?ccce=knowledgebase');
   }    
});

all being well, that should correctly modify the links... if it doesn't, then there is another modification in the background that you'll need to track down.

Link to comment
Share on other sites

Hi Brian!,

 

I have not changed any links in it, they are like this after installation.

 

Thank you for your solution. It worked for the header menu links.

I have updated the links of header menu but when I use the same code for sidebar menu it is not working.

 

On this page, http://dnhgeeks.com/customers/?ccce=knowledgebase, the announcements, knowledgebase and downloads link in secondary sidebar are not correct.

 

I have added the following code

 

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
   if (!is_null($secondarySidebar->getChild('Announcements'))) {
       $secondarySidebar->getChild('Announcements')
                   ->setURI('http://dnhgeeks.com/customers/?ccce=announcements');
   }
   if (!is_null($secondarySidebar->getChild('Knowledgebase'))) {
       $secondarySidebar->getChild('Knowledgebase')
                   ->setURI('http://dnhgeeks.com/customers/?ccce=knowledgebase');
   }
   if (!is_null($secondarySidebar->getChild('Downloads'))) {
       $secondarySidebar->getChild('Downloads')
                   ->setURI('http://dnhgeeks.com/customers/?ccce=downloads');
   }
});

 

Similarly, on page http://dnhgeeks.com/customers/?ccce=announcements to change the link of RSS Feeds on primary sidebar, I have added the following code

 

add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar)
{
if (!is_null($primarySidebar->getChild('RSS Feed'))) {
	$primarySidebar->getChild('RSS Feed')
                   ->setURI('http://dnhgeeks.com/customers/?ccce=announcementsrss');
}
});

 

None of these two codes are working. What is the problem with these two codes ?

 

What will be the code to update the links in these menus ?

Link to comment
Share on other sites

I have found the solution for updating sidebar menu items.

 

The sidebar menu items will be updated with the same code in previous post, only the menu items parent needs to be added.

 

Add the parent to menu item code for Announcements RSS using the following code

 

$primarySidebar->getChild('Announcements Months')
			->getChild('RSS Feed')
			->setUri('http://dnhgeeks.com/customers/?ccce=announcementsrss');

 

 

Thank You

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