web2008 Posted March 25, 2018 Share Posted March 25, 2018 (edited) I have a menu/hook I want to display only for one or more product groups.Is there anyone who can help me with this? function sitebuilder_hook_sidebar($sidebar) { $actions = $sidebar->getChild('Service Details Actions'); if ($actions) { $actions->addChild('Sitebuilder', array( 'name' => 'Sitebuilder', 'label' => 'Sitebuilder', 'uri' => 'index.php?m=sitebuilder', 'order' => 999, 'attributes' => array( 'target' => '_blank' Edited March 26, 2018 by WHMCS ChrisD Placed code into a code box Link to comment Share on other sites More sharing options...
brian! Posted March 26, 2018 Share Posted March 26, 2018 20 hours ago, web2008 said: I have a menu/hook I want to display only for one or more product groups.Is there anyone who can help me with this? try the following hook... <?php # Product Groups Sidebar # Written by brian! use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar) { $service = Menu::context('service'); $groupID = $service->product->productGroupId; $validgroups = ['1','2','3']; if (!in_array($groupID,$validgroups)) { return; } if (!is_null($primarySidebar->getChild('Service Details Actions'))) { $primarySidebar->getChild('Service Details Actions') ->addChild('Sitebuilder', array( 'uri' => 'index.php?m=sitebuilder', 'order' => 999, 'attributes' => array( 'target' => '_blank' ))); } }); I removed the name and label values from your hook because they were the same as the Child's name... and you only really need to add a label value if it's either a) different from the child's name or b) needs to use language strings. Link to comment Share on other sites More sharing options...
web2008 Posted March 26, 2018 Author Share Posted March 26, 2018 Thank you, this worked perfectly! Link to comment Share on other sites More sharing options...
Recommended Posts