Craft Posted December 1, 2019 Share Posted December 1, 2019 I would like to remove some SidebarNav using this hook (https://developers.whmcs.com/themes/sidebars/) I tried to remove "My Account" section in "Account Details" page with menuitemname "My Account" using the following code and it WORKS FINE :) <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { if (!is_null($primarySidebar->getChild('My Account'))) { $primarySidebar->removeChild('My Account'); } }); My issue that I would like to remove the following sections from other pages but it doesn't work. It doesn't work for "Contacts" section in "Home" page with menuitemname "Client Contacts" It doesn't work for "Shortcuts" section in "Home" page with menuitemname "Client Shortcuts" It doesn't work for "Actions" section in "Services" page with menuitemname "My Services Actions" It doesn't work for "Actions" section in "My Domains" page with menuitemname "My Domains Actions" It doesn't work for "Billing" section in "Billing" page with menuitemname "Billing" It doesn't work for "Support" section in "Support Tickets" page with menuitemname "Support" It doesn't work for "Actions" section in "View Cart" page with menuitemname "Actions" Example: if (!is_null($primarySidebar->getChild('My Services Actions'))) { $primarySidebar->removeChild('My Services Actions'); } 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 1, 2019 Share Posted December 1, 2019 8 hours ago, Craft said: My issue that I would like to remove the following sections from other pages but it doesn't work. because the sidebars you list will be secondary sidebars, not primary - so you're using the wrong hook for them. 🙂 certainly, standard_cart doesn't use primary sidebars, only secondary. i'll give you a starting point for the first two sidebars you want to hide... ... but basically it's going to be one file with two hooks in it - the first taking care of the primary sidebars (as you're currently does); the second doing the same for the secondary sidebars (with my sample code as a starting point). the code to remove these sidebars is exactly the same, you just need to choose the correct hook point for each sidebar. you could use the ClientAreaSidebars hook and that would allow you to do this in one hook point, but there's no real advantage (other than brevity of code). or if all you're going to do is hide these sidebars, and depending on the template, you might be able to do so with CSS in a custom.css file. 1 Quote Link to comment Share on other sites More sharing options...
Craft Posted December 1, 2019 Author Share Posted December 1, 2019 1 hour ago, brian! said: because the sidebars you list will be secondary sidebars, not primary - so you're using the wrong hook for them. 🙂 certainly, standard_cart doesn't use primary sidebars, only secondary. i'll give you a starting point for the first two sidebars you want to hide... ... but basically it's going to be one file with two hooks in it - the first taking care of the primary sidebars (as you're currently does); the second doing the same for the secondary sidebars (with my sample code as a starting point). the code to remove these sidebars is exactly the same, you just need to choose the correct hook point for each sidebar. you could use the ClientAreaSidebars hook and that would allow you to do this in one hook point, but there's no real advantage (other than brevity of code). or if all you're going to do is hide these sidebars, and depending on the template, you might be able to do so with CSS in a custom.css file. Perfect I did it, thank you :) 0 Quote Link to comment Share on other sites More sharing options...
Craft Posted December 1, 2019 Author Share Posted December 1, 2019 1 hour ago, brian! said: because the sidebars you list will be secondary sidebars, not primary - so you're using the wrong hook for them. 🙂 Regarding to "Open Ticket" page, the secondary sidebar nav "Support" is only appearing when there a "Recent Tickets" available. And if there is no any "Recent Tickets", the "Support" nav is disappeared. How can I show "Support" nav all the time? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 2, 2019 Share Posted December 2, 2019 23 hours ago, Craft said: How can I show "Support" nav all the time? that sidebars conditionality will be determined in an encrypted file somewhere, so the solution often suggested is a secondary sidebar hook that recreates that entire sidebar. 0 Quote Link to comment Share on other sites More sharing options...
Craft Posted December 2, 2019 Author Share Posted December 2, 2019 (edited) 48 minutes ago, brian! said: that sidebars conditionality will be determined in an encrypted file somewhere, so the solution often suggested is a secondary sidebar hook that recreates that entire sidebar. Ok fine, I found this hook to add anything to (Open Ticket) page add_hook('ClientAreaPageSubmitTicket', 1, function($vars) { if (!is_null($secondarySidebar->addChild('Test'))) { $secondarySidebar->getChild('Test') ->addChild('Test'); } }); But it doesn't work, I think I need to edit something in the code :) I tried also add_hook('ClientAreaPageSubmitTicket', 1, function(MenuItem $secondarySidebar) But doesn't work too. Reference: https://developers.whmcs.com/hooks-reference/ticket/ Edited December 2, 2019 by Craft 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 3, 2019 Share Posted December 3, 2019 21 hours ago, Craft said: Ok fine, I found this hook to add anything to (Open Ticket) page - But it doesn't work, I think I need to edit something in the code 🙂 the solution (or at least the starting point) is already out there! 🙂 looking at David's code, one obvious bug is that the uri filenames (the links in each child) should ideally end in .php (otherwise it might generate a site error) - unless you're redirecting these links outside of WHMCS. only the first three sidebar children have been created in the above hook, but hopefully you can see how simple it is to add new children for downloads, open ticket etc. 🙂 1 Quote Link to comment Share on other sites More sharing options...
Craft Posted December 5, 2019 Author Share Posted December 5, 2019 On 12/3/2019 at 2:59 PM, brian! said: the solution (or at least the starting point) is already out there! 🙂 looking at David's code, one obvious bug is that the uri filenames (the links in each child) should ideally end in .php (otherwise it might generate a site error) - unless you're redirecting these links outside of WHMCS. only the first three sidebar children have been created in the above hook, but hopefully you can see how simple it is to add new children for downloads, open ticket etc. 🙂 That's what I need exactly, thank you :) 0 Quote Link to comment Share on other sites More sharing options...
mauwiks Posted January 10, 2020 Share Posted January 10, 2020 Hi. I hope you're doing great today Guys! Just need some guidance for this "yours truly", as I'd like to remove this on my sidebar http://prntscr.com/qlu8ag Or maybe at least modify them. That's from the MarketConnect Sitelock VPN which do not hide whenever I try to hide it in the products/services settings 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 10, 2020 Share Posted January 10, 2020 if you go to the MarketConnect page in the setup menu, click on Sitelock -> manage -> Other Settings -> Landing Page Links... and switch it to off, that should remove it from the sidebar... it could be removed with a hook if it has too, but switching it off via settings would be the easiest way. 0 Quote Link to comment Share on other sites More sharing options...
mauwiks Posted January 10, 2020 Share Posted January 10, 2020 I already did this but it's still showing up http://prntscr.com/qlulzs and I actually want to only edit the sidebar and add additional links with text like the other ones if possible but it seems it's not showing 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 10, 2020 Share Posted January 10, 2020 5 minutes ago, Mauwiks said: I already did this but it's still showing up http://prntscr.com/qlulzs take a look in the other settings tab and see if the landing pages option is enabled - if so, turn it off. 13 minutes ago, Mauwiks said: I actually want to only edit the sidebar and add additional links with text like the other ones if possible but it seems it's not showing if you wanted to add other links to that sidebar, it should require a hook like the one below.... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { if (!is_null($secondarySidebar->getChild('Categories'))) { $secondarySidebar->getChild('Categories')->addChild('Other Link 1')->setUri('https://www.google.com')->setOrder(1000); } }); editing an existing child would just need getchild to the specific child and then set a new label/link etc - same with removing, just check the child exists and then remove it. 0 Quote Link to comment Share on other sites More sharing options...
mauwiks Posted January 10, 2020 Share Posted January 10, 2020 Thanks!!!!!! 0 Quote Link to comment Share on other sites More sharing options...
mauwiks Posted January 10, 2020 Share Posted January 10, 2020 I can't seem to remove 'VPN' http://prntscr.com/qlvjxe with this code: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { if (!is_null($secondarySidebar->getChild('Categories'))) { $secondarySidebar->removeChild('VPN'); } }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 10, 2020 Share Posted January 10, 2020 6 minutes ago, Mauwiks said: I can't seem to remove 'VPN' it's a child, so you'll need to grab the parent first... $secondarySidebar->getChild('Categories')->removeChild('VPN'); this should work assuming that another hook hasn't removed it, or you disable it in the settings.... and it's actually called VPN (it might be 'vpn'). 0 Quote Link to comment Share on other sites More sharing options...
mauwiks Posted January 10, 2020 Share Posted January 10, 2020 Yes, I already interchange them but still don't: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { if (!is_null($secondarySidebar->getChild('Categories'))) { $secondarySidebar->getChild('Categories')->removeChild('vpn'); } }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 10, 2020 Share Posted January 10, 2020 3 minutes ago, Mauwiks said: Yes, I already interchange them but still don't: if you look at the page source in the browser, what's the menuitemname value for VPN ? whatever that value is, that will be what you need to use in the hook. 0 Quote Link to comment Share on other sites More sharing options...
mauwiks Posted January 10, 2020 Share Posted January 10, 2020 This http://prntscr.com/qlxg84 I tried it but nothing. I'll check some 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 10, 2020 Share Posted January 10, 2020 from that, it should be sitelockvpn - if that gets you nowhere, it has an ID value - so you could hide it using CSS as a last resort. 0 Quote Link to comment Share on other sites More sharing options...
mauwiks Posted January 10, 2020 Share Posted January 10, 2020 Not sure how to do CSS lol 0 Quote Link to comment Share on other sites More sharing options...
mauwiks Posted January 10, 2020 Share Posted January 10, 2020 Got the issue. It didn't work earlier because I renamed the file ""sidebars.php_disabled" lol. What the........... I wasted almost an hour of thinking about what's going on. Cheers. 😄 Thanks Bry! @brian! As usual....... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { if (!is_null($secondarySidebar->getChild('Categories'))) { $secondarySidebar->getChild('Categories')->removeChild('sitelockvpn'); } }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 10, 2020 Share Posted January 10, 2020 Just now, Mauwiks said: It didn't work earlier because I renamed the file ""sidebars.php_disabled" lol. lol - i've been there. 🙄 1 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.