D9Hosting Posted July 18, 2017 Share Posted July 18, 2017 I'm working on a new WHMCS theme based on Six and have been having a bit of fun in getting the navigation and sidebars to work how we want. I've been able to create hooks to add and remove items from existing nav bars and sidebars but have become stuck on creating a brand new sidebar to display on our Affiliate pages. We use the default affiliates.php page, but also have custom pages to display promo banners, email swipes, discount coupons, etc. So wondered if any coding guru's reading this could point me in the right direction for generating a new sidebar item and then to have it display on certain pages. (affiliates.php and our custom pages) Thanks! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted July 18, 2017 Share Posted July 18, 2017 as a basic example, to add a new sidebar to only the affiliates page, you could do something like this... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { if (APP::getCurrentFileName()=="affiliates"){ $secondarySidebar->addChild('sidebar1', array( 'label' => 'My New Sidebar', 'order' => '10', 'icon' => 'fa-money' )); $secondarySidebar->getChild('sidebar1') ->addChild('child1', array( 'label' => 'Brian', 'uri' => 'http://www.google.com' )); } }); to use on multiple pages, you can just expand that opening IF statement to use all the pages where you want this sidebar to appear.... if you need to use templatefile to specify a template rather than a page, the thread below might help. https://forum.whmcs.com/showthread.php?125626-How-to-get-templatefile-in-a-hook-and-use-client-Custom-Fields-in-a-SideBar and remember that sidebar children can't have the same name, so you can call them 'child1', 'child2' etc or whatever you want - as long as the names are unique. 0 Quote Link to comment Share on other sites More sharing options...
D9Hosting Posted July 19, 2017 Author Share Posted July 19, 2017 Thanks Brian, That pointed me in the right direction and I've hacked the following together that seems to be working well if anyone else runs into the same issue: <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { $currentFile = APP::getCurrentFileName(); switch ($currentFile) { case 'custompage1': case 'custompage2': case 'custompage3': $secondarySidebar->addChild('sidebar1', array( 'label' => 'My New Sidebar', 'order' => '10', 'icon' => 'fa-money' )); $secondarySidebar->getChild('sidebar1') ->addChild('child1', array( 'label' => 'Brian', 'uri' => 'http://www.google.com' )); break; } }); 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.