Jump to content

Can't seturi on hooks


mifta

Recommended Posts

Hello i have a third part module and it Just have admin area and i want to add a feature in client area so i added a hooks, but when i added it the submenu appear but when i clicked it there's warningg " opps could t find that Page" 

Link to comment
Share on other sites

  • 7 months later...
15 hours ago, jimsweb said:

yes, setUri seems no longer working after v8.0 upgrade.

are you sure?? if I write a quick hook to change the link on the home navbar, it works fine...

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)
{
	if (!is_null($primaryNavbar->getChild('Home'))) {
		$primaryNavbar->getChild('Home')->setUri('https://google.com');
	}
});
On 02/03/2020 at 04:14, mifta said:

Hello i have a third part module and it Just have admin area and i want to add a feature in client area so i added a hooks, but when i added it the submenu appear but when i clicked it there's warningg " opps could t find that Page" 

enable error reporting and it should give you more details as to the cause of the error...

https://docs.whmcs.com/Enabling_Error_Reporting

Link to comment
Share on other sites

I'm having the same (similar?) issue which happened after our version 8 update.  My WHMCS's primary domain is being prepended to the URI as such:

if (!is_null($primaryNavbar->getChild('Support')->getChild('Tickets'))) {
        $primaryNavbar->getChild('Support')->getChild('Tickets')->setUri('https://theintendeduri.com/targetpage');
        $primaryNavbar->getChild('Support')->getChild('Tickets')->setAttribute("target", '_blank');
   }

Produces this link:

https://ourwhmcsdomain.com/https://theintendeduri.com/targetpage

This, of course, will produce a 404.

Edited by sclemance
Code snippet correction...
Link to comment
Share on other sites

  • 2 weeks later...

After some testing, it seems if I use (or concatenate) a variable, such as $myUri, it prepends the base installation URL.  Specifically, if I do this:

$navItem->setUri('https://newsite.com');

It works, and I get a link that looks like this:  'https://newsite.com'

This also seems to work fine:

$moreStuff = '/support';
$navItem->setUri('https://newsite.com' . $moreStuff);

...and I get a link that looks like: 'https://newsite.com/supprt'

But if I do this:

$myUri = 'https://newsite.com/support?client=' . $clientName;
$navItem->setUri($myUri);

...the link ends up looking like this:  'https://mywhmcsurl.com/https://newsite.com/support?client=MrCustomer'

And if I do this:

$navItem->setUri('noProtocolOrDomain');

...I get a link that looks like this:  'https://mywhmcsurl.com/noProtocolOrDomain'

Leading me to believe there is some sort of glitch with the way WHMCS is parsing the URL parameters before intelligently deciding if the base URL needs to be prepended.  Any thoughts?

 

UPDATE:  As I was about to submit this, I realized that even though the link produced with the prepended base WHMCS URLs looked okay otherwise, (and even worked if I chopped off the prepended bit), I wasn't using urlencode on the variables.  Individually using urlencode on each variable allowed WHMCS to parse the string correctly and it's working now.  We'll chalk that up to my rusty coding and 'zen-less' disposition lately.  I'll leave my mess above in the post in case it helps anyone else.

Link to comment
Share on other sites

  • 3 months later...

This is also a issue for me. 

 

    $primaryNavbar->addChild('Dashboard')
        ->setUri('https://client.domain.io/')
        ->setIcon('fa-tachometer')
        ->setOrder(1);

 

Creates a functioning item, with a icon.

 

However, URI doesn't change at all.

Edited by iwanndie
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