Jump to content

Editing Menu Items & Email Template


CJF077

Recommended Posts

Hi Guys,

I seem to have lost my touch, as we have not been using WHMCS for a while and things are a little chaotic.

I need to do a few things.

1. Change the email template. Would like to restore it to the original, but cannot figure our the files or what was in the original email template header & footer. We have our old business name, and want to update it.

2. I need to edit the menu items. I want to point announcements, knowledgebase and support to an external helpdesk system. This I am presuming would need to be done in both the top menu, bottom menu, and of course once logged in. 

Any suggestions, on restoring me to sanity would be appreciated.

Link to comment
Share on other sites

10 hours ago, CJF077 said:

1. Change the email template. Would like to restore it to the original, but cannot figure our the files or what was in the original email template header & footer. We have our old business name, and want to update it.

they would have stored in the database tables - the individual email templates would be in tblemailtemplates; and the header/footer/css would be in tblconfiguration - so if you have old database backups, you should be able to recover them from there.

10 hours ago, CJF077 said:

2. I need to edit the menu items. I want to point announcements, knowledgebase and support to an external helpdesk system. This I am presuming would need to be done in both the top menu, bottom menu, and of course once logged in. 

difficult to answer without seeing what you're seeing... though if it's any recent version of WHMCS (e.g the last 3 years!), then you might be looking at using action hooks to modify the menu.

https://docs.whmcs.com/Editing_Client_Area_Menus

10 hours ago, CJF077 said:

Any suggestions, on restoring me to sanity would be appreciated.

using hooks to modify the menus might send you over the edge... so sanity restoration might be above my skill set. 🙂

Link to comment
Share on other sites

This may work to remove certain menu items

Save into /includes/hooks/

<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
    if (!is_null($primaryNavbar->getChild('Knowledgebase'))) {
        $primaryNavbar->removeChild('Knowledgebase');
    }
});

The following allows you to add custom external links

 

 

<?php
#adding Menu Item to primaryNavbar
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
    $primaryNavbar->addChild('Support')
        ->setUri('https://za.domains/')
        ->setOrder(70);
});

 

Link to comment
Share on other sites

actually, what he probably wants is a combination of the two... e.g redirect existing links...

<?php
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
    if (!is_null($primaryNavbar->getChild('Knowledgebase'))) {
        $primaryNavbar->getChild('Knowledgebase')
          ->setUri('https://google.com');
    }
});

but once we know what he's seeing, then the advice can be clearer!

Link to comment
Share on other sites

18 hours ago, brian! said:

they would have stored in the database tables - the individual email templates would be in tblemailtemplates; and the header/footer/css would be in tblconfiguration - so if you have old database backups, you should be able to recover them from there.

difficult to answer without seeing what you're seeing... though if it's any recent version of WHMCS (e.g the last 3 years!), then you might be looking at using action hooks to modify the menu.

https://docs.whmcs.com/Editing_Client_Area_Menus

using hooks to modify the menus might send you over the edge... so sanity restoration might be above my skill set. 🙂

Unfortunately do not have a backup of the old template...  so a copy of the original would be appreciated (email template)

Yep the redirection is what is needed. Managed to do the knowledge base, but also need to redirect support in the menu. Have attached some screenshots of what I need changed.

One is the main menu, not logged in.

Other is side menu, when clicked on eg announcements

Other is menu at top when logged in and side menu.

Need to redirect them to two different URL's.

Can we use one HOOK file to do all? 

2018-10-04_17-42-01.jpg

2018-10-04_17-43-37.jpg

2018-10-04_17-45-27.jpg

Link to comment
Share on other sites

  • WHMCS Support Manager
1 hour ago, CJF077 said:

Unfortunately do not have a backup of the old template...  so a copy of the original would be appreciated (email template)

In WHMCS 7.6 and above, you can find this data in the /resources/sql/install/tblemailtemplates.data.sql file.

Link to comment
Share on other sites

6 hours ago, CJF077 said:

Yep the redirection is what is needed. Managed to do the knowledge base, but also need to redirect support in the menu. Have attached some screenshots of what I need changed.

i've posted the hooks to do all these things previously - though it would probably take me longer to find those links than it would to write the hook again!

7 hours ago, CJF077 said:

Need to redirect them to two different URL's.

specifically to this point, are you saying that the sidebar links need to be different based on whether the client is logged in or not... e.g if they're logged in, the Announcements links go to google.com; if they aren't logged in, they go to apple.com - or are they going to the same link regardless of whether they're logged in or not ??

Link to comment
Share on other sites

14 hours ago, WHMCS John said:

In WHMCS 7.6 and above, you can find this data in the /resources/sql/install/tblemailtemplates.data.sql file.

I dont believe that is it.

I am referring to the info in General Settings >> Mail

Global Email CSS Styling
Client Email Header Content
Client Email Footer Content

Link to comment
Share on other sites

7 hours ago, brian! said:

i've posted the hooks to do all these things previously - though it would probably take me longer to find those links than it would to write the hook again

specifically to this point, are you saying that the sidebar links need to be different based on whether the client is logged in or not... e.g if they're logged in, the Announcements links go to google.com; if they aren't logged in, they go to apple.com - or are they going to the same link regardless of whether they're logged in or not ??

Ill try and do a search for the hooks.... thanks for this.

No the links will be the same for eg logging a support ticket, but the link for viewing may be different eg www.example.com/submitticket to www.example.com/viewticket

Edited by CJF077
Link to comment
Share on other sites

4 hours ago, CJF077 said:

I dont believe that is it.

I am referring to the info in General Settings >> Mail

Global Email CSS Styling
Client Email Header Content
Client Email Footer Content

Managed to find this in another thread. Fixed...  Thanks for your help with this.

Link to comment
Share on other sites

On 05/10/2018 at 04:47, CJF077 said:

Managed to find this in another thread. Fixed...  Thanks for your help with this.

for the benefit of others reading this, it's in the docs.

https://docs.whmcs.com/Email_Styling

On 05/10/2018 at 00:37, CJF077 said:

No the links will be the same for eg logging a support ticket, but the link for viewing may be different eg www.example.com/submitticket to www.example.com/viewticket

I think that i'm slightly more confused now than I was in the first place. 🤕

let me give you a single hook file that changes all the links you want, and then if there are any required tweaks, you can get back to me...

<?php

# Menu/Sidebar Link Changes Hook for CJF077
# Written by brian!

use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	if (!is_null($primaryNavbar->getChild('Knowledgebase'))) {
		$primaryNavbar->getChild('Knowledgebase')
			->setUri('https://google.com');
	}
	if (!is_null($primaryNavbar->getChild('Announcements'))) {
		$primaryNavbar->getChild('Announcements')
			->setUri('https://google.com');
	}
	if (!is_null($primaryNavbar->getChild('Open Ticket'))) {
		$primaryNavbar->getChild('Open Ticket')
			->setUri('https://google.com');
	}
	if (is_null($primaryNavbar->getChild('Support'))) {
		return;
	}	
	if (!is_null($primaryNavbar->getChild('Support')->getChild('Tickets'))) {
		$primaryNavbar->getChild('Support')
			->getChild('Tickets')
			->setUri('https://google.com');
	}	
	if (!is_null($primaryNavbar->getChild('Support')->getChild('Announcements'))) {
		$primaryNavbar->getChild('Support')
			->getChild('Announcements')
			->setUri('https://google.com');
	}	
	if (!is_null($primaryNavbar->getChild('Support')->getChild('Knowledgebase'))) {
		$primaryNavbar->getChild('Support')
			->getChild('Knowledgebase')
			->setUri('https://google.com');
	}	
});

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
	if (is_null($secondarySidebar->getChild('Support'))) {
		return;
	}
	if (!is_null($secondarySidebar->getChild('Support')->getChild('Support Tickets'))) {
		$secondarySidebar->getChild('Support')
			->getChild('Support Tickets')
			->setUri('https://google.com');
	}	
	if (!is_null($secondarySidebar->getChild('Support')->getChild('Announcements'))) {
		$secondarySidebar->getChild('Support')
			->getChild('Announcements')
			->setUri('https://google.com');
	}	
	if (!is_null($secondarySidebar->getChild('Support')->getChild('Knowledgebase'))) {
		$secondarySidebar->getChild('Support')
			->getChild('Knowledgebase')
			->setUri('https://google.com');
	}	
	if (!is_null($secondarySidebar->getChild('Support')->getChild('Open Ticket'))) {
		$secondarySidebar->getChild('Support')
			->getChild('Open Ticket')
			->setUri('https://google.com');
	}
});

function change_homeshortcuts_support_link_hook($vars)
{
	return "<script>document.getElementById('btnGetSupport').href = 'https://www.google.com';</script>";
};
add_hook("ClientAreaFooterOutput",1,"change_homeshortcuts_support_link_hook");

to keep things simple, i've changed all the links to redirect to Google, so you can work your way through the hook and change them to more relevant links (those link URLs should be the only changes required to the hook).

  • the first three navbar links are for non-logged in users.
  • the support navbar links are for logged in users... i'm not specifically checking that the user is logged in because if they weren't, they wouldn't see these links!
  • the four sidebar links will only be shown to logged in users - again, as that condition exists, we don't need to check if they're logged in...
  • the last hook changes the link in the shortcuts menu.
Link to comment
Share on other sites

Need a few more minor things. Hoping I can get some guidance Brian.

On the email template that goes out, I want to add some info into a table next to the logo:

Current Email header is this:

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <style type="text/css">
            [EmailCSS]
        </style>
    </head>
    <body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0">
        <center>
            <table align="center" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="bodyTable">
                <tr>
                    <td align="center" valign="top" id="bodyCell">
                        <table border="0" cellpadding="0" cellspacing="0" id="templateContainer">
                            <tr>
                                <td align="center" valign="top">
                                    <table border="0" cellpadding="0" cellspacing="0" width="100%" id="templateHeader">
                                        <tr>
                                            <td valign="top" class="headerContent">
                                                <a href="{$company_domain}">
                                                    <img src="{$company_logo_url}" style="max-width:600px;padding:20px" id="headerImage" alt="{$company_name}" />
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" valign="top">
                                    <table border="0" cellpadding="0" cellspacing="0" width="100%" id="templateBody">
                                        <tr>
                                            <td valign="top" class="bodyContent">        

 

Link to comment
Share on other sites

13 hours ago, CJF077 said:

On the email template that goes out, I want to add some info into a table next to the logo:

I guess the viability of that depends on your logo, it's size and required space needed for the table.

at it's most basic, you could add text next to the logo...

<img src="{$company_logo_url}" style="max-width:100px;padding:20px" id="headerImage" alt="{$company_name}" />hello world

YinU9QM.png

depending on what you've go in mind, another option would be to make an image banner, including your logo and text, and use that - that should remove the need to mess around with the css.

Link to comment
Share on other sites

  • 2 weeks later...

Hi wondering if you can help me out, 

I tried following all of the above, I managed to get it working if logged in but for logged out users it would chuck them up with an oops page. 

I have done some debugging and put some code back in and no more errors but the hook is no longer changing the URL. can I pick your brains for a moment and take a look at the code I am using and point me in the right direction?

All I am trying to achieve is to redirect the standard knowledge base article links in the menu / secondary menu etc to another URL

Thanks

 

<?php

# Menu/Sidebar Link Changes Hook for CJF077
# Written by brian!

use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	if (!is_null($primaryNavbar->getChild('Knowledgebase'))) {
		$primaryNavbar->getChild('Knowledgebase')
			->setURI('https://google.com');
	}
	
	
	if (is_null($primaryNavbar->getChild('Support'))) {
		return;
		}
		
	if (!is_null($primaryNavbar->getChild('Support')->getChild('Knowledgebase'))) {
		$primaryNavbar->getChild('Support')
			->getChild('Knowledgebase')
			->setURI('https://google.com');
	}
});

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
	if (is_null($secondarySidebar->getChild('Support'))) {
		return;
	}
	
	
	if (!is_null($secondarySidebar->getChild('Support')->getChild('Knowledgebase'))) {
		$secondarySidebar->getChild('Support')
			->getChild('Knowledgebase')
			->setURI('https://google.com');
	}	
	
});

 

Link to comment
Share on other sites

15 hours ago, Dean Walker said:

I have done some debugging and put some code back in and no more errors but the hook is no longer changing the URL. can I pick your brains for a moment and take a look at the code I am using and point me in the right direction?

All I am trying to achieve is to redirect the standard knowledge base article links in the menu / secondary menu etc to another URL

there seems to be invalid characters all over your code - hopefully the following clean version should work for you (working locally)...

<?php

# Menu/Sidebar Link Changes Hook for Dean Walker
# Written by brian!

use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	if (!is_null($primaryNavbar->getChild('Knowledgebase'))) {
		$primaryNavbar->getChild('Knowledgebase')
			->setUri('https://google.com');
	}
	if (is_null($primaryNavbar->getChild('Support'))) {
		return;
	}	
	if (!is_null($primaryNavbar->getChild('Support')->getChild('Knowledgebase'))) {
		$primaryNavbar->getChild('Support')
			->getChild('Knowledgebase')
			->setUri('https://google.com');
	}	
});

add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar)
{
	if (is_null($secondarySidebar->getChild('Support'))) {
		return;
	}
	if (!is_null($secondarySidebar->getChild('Support')->getChild('Knowledgebase'))) {
		$secondarySidebar->getChild('Support')
			->getChild('Knowledgebase')
			->setUri('https://google.com');
	}	
});

 

Link to comment
Share on other sites

  • 2 years later...

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