bigsean Posted February 8, 2018 Share Posted February 8, 2018 Hi, I use the following code to hide the Support menu from a specific page and it works fine (code is for when a client is logged in): <?php use WHMCS\View\Menu\Item as MenuItem; if (App::getCurrentFilename() == 'viewticket') add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { $client = Menu::context('client'); if (!is_null($client)) { if (!is_null($secondarySidebar->getChild('Support'))) { $secondarySidebar->removeChild('Support') ->removeChild('Announcements') ->removeChild('Knowledgebase') ->removeChild('Downloads') ->removeChild('Network Status') ->removeChild('Open Ticket'); } } } ); My issues is that I want to hide the same Support menu on the Knowledgebase page when the client is logged in however the Knowledgebase friendly URL is not a file path and so I'm not sure how to edit the code to reference this. The URL in the address bar is xyz.com/whmcs/knowledgebase (example). Thanks Link to comment Share on other sites More sharing options...
brian! Posted February 8, 2018 Share Posted February 8, 2018 the way I would probably do it as follows... <?php /** * Hide Support Sidebar On Specific Pages * @author brian! */ use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { GLOBAL $smarty; $templatefile = $smarty->getVariable('templatefile'); $allowed = array('viewticket','knowledgebase','knowledgebasecat','knowledgebasearticle'); $client = Menu::context('client'); if (in_array($templatefile, $allowed)) { if (!is_null($client) && !is_null($secondarySidebar->getChild('Support'))) { $secondarySidebar->removeChild('Support'); } } }); so instead of using pages, you're now using template filenames - that will allow you to be more accurate and flexible going forward if you want to expand this - they won't change regardless of whatever friendly url setting you use. additionally, i've omitted a lot of your removes - once you remove the parent entry of the sidebar, you don't need to remove the children too. Link to comment Share on other sites More sharing options...
bigsean Posted February 8, 2018 Author Share Posted February 8, 2018 Thank you, Brian! That worked and using template files makes much more sense. Note: You referenced 'viewticket' however on the View Ticket page (Once logged in obvs) the Support sidebar is still visible. I'm not sure if it's something else in my template system as it's not heavily modified at all. There is of course a viewticket.tpl so it really should just work. I cleared the template cache just to be sure but it's still visible. I used my original file name method hook temporarily for that specific page but it's just odd that it still shows on that page. Link to comment Share on other sites More sharing options...
brian! Posted February 8, 2018 Share Posted February 8, 2018 12 minutes ago, bigsean said: Note: You referenced 'viewticket' however on the View Ticket page (Once logged in obvs) the Support sidebar is still visible. I'm not sure if it's something else in my template system as it's not heavily modified at all. There is of course a viewticket.tpl so it really should just work. I cleared the template cache just to be sure but it's still visible. I used my original file name method hook temporarily for that specific page but it's just odd that it still shows on that page. I thought I tested it on viewticket... hmm seems you are right. in that case, we'll mix&match for now - filenames and template names... <?php /** * Hide Support Sidebar On Specific Pages * @author brian! */ use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { GLOBAL $smarty; $templatefile = $smarty->getVariable('templatefile'); $filename = $smarty->getVariable('filename'); $allowedtemplates = array('knowledgebase','knowledgebasecat','knowledgebasearticle'); $allowedfiles = array('viewticket'); $client = Menu::context('client'); if (in_array($templatefile, $allowedtemplates) or in_array($filename, $allowedfiles)) { if (!is_null($client) && !is_null($secondarySidebar->getChild('Support'))) { $secondarySidebar->removeChild('Support'); } } }); 1 Link to comment Share on other sites More sharing options...
Recommended Posts