Jump to content

Issue with your docs for MenuRepository::addContext()


Recommended Posts

I updated to PHP 7.1 and im getting the following error:

[Wed Jun 17 09:12:52 2020] [notice] [client 1.2.3.4] [host abc.com] Backend log: [WHMCS Application] ERROR: ArgumentCountError: Too few arguments to function WHMCS\View\Client\Menu\MenuRepository::addContext(), 0 passed in /var/www/vhtdocs/usersite/html/vendor/illuminate/support/Facades/Facade.php on line 215 and exactly 2 expected in /var/www/vhtdocs/usersite/html/vendor/whmcs/whmcs-foundation/lib/View/Client/Menu/MenuRepository.php:0 Stack trace: #0 /var/www/vhtdocs/usersite/html/vendor/illuminate/support/Facades/Facade.php(215): WHMCS\View\Client\Menu\MenuRepository->addContext() #1 /var/www/vhtdocs/usersite/html/domaindns.php(866): Illuminate\Support\Facades\Facade::__callStatic('addContext', Array) #2 {main} {"exception":"[object] (ArgumentCountError(code: 0): Too few arguments to function WHMCS\\View\\Client\\Menu\\MenuRepository::addContext(), 0 passed in /var/www/vhtdocs/usersite/html/vendor/illuminate/support/Facades/Facade.php on line 215 and exactly 2 expected at /var/www/vhtdocs/usersite/html/vendor/whmcs/whmcs-foundation/lib/View/Client/Menu/MenuRepository.php:0)"} []\n, referer: https://www.abc.com/clientarea.php?action=domaindetails&id=1234

My code is:
Menu::addContext();
Menu::primarySidebar('domainView');

And this was working but not is not. Can I get a sample of how to do this as per your docs and this page https://whmcs.community/topic/286293-error-too-few-arguments-passed-menurepositoryaddcontext/ the addContext is suppose to have two arguments passed to it, but your example here does not:
https://developers.whmcs.com/advanced/creating-pages/

I realize it should be something like:
            Menu::addContext('client',  ??????);
            Menu::addContext('domain',  ?????);
            Menu::primarySidebar('domainView');

But the second arguments for addContext is what I dont know how to do and your docs dont have examples.

I want to update my code so I can show the domainView sidebar page like it does within whmcs on the domains management page. Please help!

Link to comment
Share on other sites

Something like this would have been helpful..

https://github.com/WHMCS/developer-docs/issues/22

I figured it out via that link..

            $currentUser = Client::find($_SESSION['uid']); 
            $currentDomain = Domain::find($_GET["id"]);
            Menu::addContext('client', $currentUser);
            Menu::addContext('domain', $currentDomain);
            Menu::primarySidebar('domainView');

Now to get the  default WHMCS secondary Domain Action Bar to show up...

Menu::secondarySidebar('domainAction');

Errors out: Backend log: [WHMCS Application] ERROR: WHMCS\\Exception: Unknown sidebar "domainAction". in /vendor/whmcs/whmcs-foundation/lib/View/Client/Menu/MenuRepository.php:0 

Link to comment
Share on other sites

8 minutes ago, WHMCS Dan said:

Can you perhaps clarify what is unclear in the documentation? 

The addContext is used to set the context of the menu, so for example for a client menu it would be:

Menu::addContext('client',  Client::find($_SESSION['uid']));

 

This part was unclear:  Client::find($_SESSION['uid'])  ..... how to use WHMCS Classes correctly since your doc is all wrong here: https://developers.whmcs.com/advanced/creating-pages/

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