monsterit Posted July 2, 2018 Share Posted July 2, 2018 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** 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 2, 2018 Share Posted July 2, 2018 as per previous threads, you need to check that the sidebar exists before you try to modify it. 1 Quote Link to comment Share on other sites More sharing options...
monsterit Posted July 3, 2018 Author Share Posted July 3, 2018 It does exsist in the client panel. But not on the front page. So i thought that would work. here's a screen grab of the panel backend. 0 Quote Link to comment Share on other sites More sharing options...
Vox Posted July 4, 2018 Share Posted July 4, 2018 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/'); }); 0 Quote Link to comment Share on other sites More sharing options...
monsterit Posted July 4, 2018 Author Share Posted July 4, 2018 Yeah tried that but still the same 😢 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 4, 2018 Share Posted July 4, 2018 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! 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/'); } }); 1 Quote Link to comment Share on other sites More sharing options...
Vox Posted July 4, 2018 Share Posted July 4, 2018 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! 0 Quote Link to comment Share on other sites More sharing options...
monsterit Posted July 4, 2018 Author Share Posted July 4, 2018 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. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 5, 2018 Share Posted July 5, 2018 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. 0 Quote Link to comment Share on other sites More sharing options...
monsterit Posted July 5, 2018 Author Share Posted July 5, 2018 ah okay. Thank you. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.