Jump to content

Sidebar Menu issues with six theme


HostworX

Recommended Posts

Hi,

 

I have tried adding an additional menu option to the client area "My Account" Menus, this is effectively done by adding the following code to a hook file, which then adds the menu line to the menu..... However there is a catch ... read below after the code

 

This is the code you add to the hook file according to the whmcs cheatsheet. http://docs.whmcs.com/Client_Area_Sidebars_Cheatsheet

 

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
   $primarySidebar->getChild('My Account')
       ->addChild('Mailing List Subscription Prefs', array(
           'label' => 'Subscription Preferences',
           'uri' => 'subscriptionprefs.php',
           'order' => '100',
       ));
});

 

 

The issue is this code works while you are in the 5 menus under this option, exit to the clientarea.php or any other page that is not part of the client area menu, and the site crashes because of this code. take the hook away and the site works fine. If you use the other snippets they offer to add social icons etc this works throughout the site no problems.

 

It is only happening on the "My account" coding, so I think either whmcs has slipped up here, or there must be some way of telling the hook file not to run on pages other the the my account pages.

 

Can someone maybe shed some light on this.

Link to comment
Share on other sites

sometimes you have to read the other cheatsheets and documentation to find a clue as to how to do something... and then experiment!

 

try...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar)
{
   if (!is_null($primarySidebar->getChild('My Account'))) {
                 $primarySidebar->getChild('My Account')
                                      ->addChild('Mailing List Subscription Prefs', array(
                             'label' => 'Subscription Preferences',
                                'uri' => 'subscriptionprefs.php',
                            'order' => '100',
       ));
}
});

Link to comment
Share on other sites

Hi Brian,

 

Thks for the help whmcs sent me a fix yesterday but it didnt work, the issue was they defined the one line of code as

 

if (!is_null($primaryNavbar->getChild('My Account'))) {

 

The error being $primaryNavbar should have been $primarySidebar

 

Your coding fixed the issue here !! :idea: kudos

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.

×
×
  • 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