justaserverguy Posted June 1, 2020 Share Posted June 1, 2020 Hello! I am trying to see how I can edit and remove certain sidebar items. I have gone over the guides on editing the sidebar using hooks but have not found how I can hide certain items. I am using an external service for knowledge base, network status and announcements. Is it possible to change the url these go to when clicked from within the client area sidebar? I do not use the downloads feature so I would like to be able to hide that. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 2, 2020 Share Posted June 2, 2020 10 hours ago, justaserverguy said: Is it possible to change the url these go to when clicked from within the client area sidebar? yes... if you ignore the navbar parts and just focus on the sidebar part of the hook below, that can be used to change the links in that sidebar... 10 hours ago, justaserverguy said: I do not use the downloads feature so I would like to be able to hide that. if you're doing that in a hook, then it's just a removeChild. if (!is_null($secondarySidebar->getChild('Support'))) { $secondarySidebar->getChild('Support')->removeChild('Downloads'); } 1 Quote Link to comment Share on other sites More sharing options...
justaserverguy Posted June 2, 2020 Author Share Posted June 2, 2020 8 hours ago, brian! said: yes... if you ignore the navbar parts and just focus on the sidebar part of the hook below, that can be used to change the links in that sidebar... if you're doing that in a hook, then it's just a removeChild. if (!is_null($secondarySidebar->getChild('Support'))) { $secondarySidebar->getChild('Support')->removeChild('Downloads'); } Sorry if this is a dumb question, I am going to Includes/Hooks but there is nothing in there. Am i going to the wrong spot or do I need to create files for these inside of includes/hooks? 0 Quote Link to comment Share on other sites More sharing options...
justaserverguy Posted June 2, 2020 Author Share Posted June 2, 2020 Follow up - I created a new file and used a hook you mentioned in another post to get rid of the recent news in the client area. When I try to follow the same steps to edit the sidebar it doesn't seem to work. I must be doing something wrong. 0 Quote Link to comment Share on other sites More sharing options...
justaserverguy Posted June 3, 2020 Author Share Posted June 3, 2020 Update: I was able to get the hooks to work on my dev site but for some reason it does not work on the live site. 🤦♂️ guess it's going to be a late night. Thanks for the help @brian! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 3, 2020 Share Posted June 3, 2020 i'd need to see the code - but it's worth mentioning that you don't necessarily need them in separate files - you can put associated hooks in the same .php file and then you can keep a clearer handle on what you're changing. 0 Quote Link to comment Share on other sites More sharing options...
justaserverguy Posted June 3, 2020 Author Share Posted June 3, 2020 2 hours ago, brian! said: i'd need to see the code - but it's worth mentioning that you don't necessarily need them in separate files - you can put associated hooks in the same .php file and then you can keep a clearer handle on what you're changing. Here is what I came up with. What is also strange is that it works when in the downloads, announcement, knowledge base and server status pages. But when in the Support Tickets or Open Tickets page it pulls the default sidebar. 🤔 <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) { if (is_null($secondarySidebar->getChild('Support'))) { return; } if (!is_null($secondarySidebar->getChild('Support')->getChild('Announcements'))) { $secondarySidebar->getChild('Support') ->getChild('Announcements') ->setUri('https://www.blog.example.com'); } if (!is_null($secondarySidebar->getChild('Support')->getChild('Knowledgebase'))) { $secondarySidebar->getChild('Support') ->getChild('Knowledgebase') ->setUri('https://www.help.example.com'); } if (!is_null($secondarySidebar->getChild('Support'))) { $secondarySidebar->getChild('Support')->removeChild('Downloads'); } if (!is_null($secondarySidebar->getChild('Support')->getChild('Network Status'))) { $secondarySidebar->getChild('Support') ->getChild('Network Status') ->setUri('https://www.example.statuspage.io/'); } }); function change_homeshortcuts_support_link_hook($vars) { return "<script>document.getElementById('btnGetSupport').href = 'https://www.help.example.com';</script>"; }; add_hook("ClientAreaFooterOutput",1,"change_homeshortcuts_support_link_hook"); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted June 4, 2020 Share Posted June 4, 2020 15 hours ago, justaserverguy said: What is also strange is that it works when in the downloads, announcement, knowledge base and server status pages. But when in the Support Tickets or Open Tickets page it pulls the default sidebar. FWIW - i'm not noticing that occurring locally when I test the hook... 0 Quote Link to comment Share on other sites More sharing options...
justaserverguy Posted June 4, 2020 Author Share Posted June 4, 2020 2 hours ago, brian! said: FWIW - i'm not noticing that occurring locally when I test the hook... That helps thanks. Since you have no issues and my dev site had no issues my guess is it has to do with some changes I may have done to the template. Thanks @brian! 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.