Jump to content

Changing sidebar link stops index.php


Recommended Posts

Hi,


When i have this code in the hooks folder.

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $primarySidebar)
{
    $primarySidebar->getChild('Support')
        ->getChild('Open Ticket')
		->setLabel('Helpdesk')
        ->setUri('https://monsterit.servicedesk.comodo.com/');
});

 

the homepage index.php shows this error. **Attached**

 

 

Capture.PNG

Link to comment
Share on other sites

Hi monsterit,

I'm still learning this stuff (as WHMCS has the worst menu system I've ever used - as a non-coder) but it looks like you've mixed references and actions for two different Sidebars.

Should all of this be in reference to the SecondarySidebar?

On 7/2/2018 at 9:33 AM, monsterit said:

 


<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $primarySidebar)
{
    $primarySidebar->getChild('Support')
        ->getChild('Open Ticket')
		->setLabel('Helpdesk')
        ->setUri('https://monsterit.servicedesk.comodo.com/');
});

 

i.e.

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar)
{
    $secondarySidebar->getChild('Support')
        ->getChild('Open Ticket')
        ->setUri('https://monsterit.servicedesk.comodo.com/');
});

 

Link to comment
Share on other sites

19 minutes ago, Vox said:

I'm still learning this stuff (as WHMCS has the worst menu system I've ever used - as a non-coder)

it's not that great as a coder either! :wall1:

20 minutes ago, Vox said:

but it looks like you've mixed references and actions for two different Sidebars.

Should all of this be in reference to the SecondarySidebar?

@Vox is absolutely correct with this - it's the cross-references of primary/secondary sidebar that will one reason why it's not working... the other will be that you need to check that the sidebar/navbar being modified exists, because if it doesn't, (e.g if you try either of the above hooks on any page where that sidebar doesn't exist), you'll get an error...

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar)
{
	if(!is_null($secondarySidebar->getChild('Support'))){
				$secondarySidebar->getChild('Support')
				->getChild('Open Ticket')
				->setLabel('Helpdesk')
				->setUri('https://monsterit.servicedesk.comodo.com/');
	}
});

 

 

Link to comment
Share on other sites

6 minutes ago, brian! said:

you need to check that the sidebar/navbar being modified exists, because if it doesn't, (e.g if you try either of the above hooks on any page where that sidebar doesn't exist), you'll get an error...

Thanks @brian! it really is a struggle to get to ggrips with this so every little snippet helps!

Link to comment
Share on other sites

21 hours ago, monsterit said:

Ah i see so if it's not shown on the main page for instance index.php then it will throw an error up. I get it now i'll just disable the bar altogether i think.

unless you've modified the navbar, those links will be in there too by default - so that sidebar is just a duplication of those links.

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