isixhosting Posted March 14, 2017 Share Posted March 14, 2017 Hi WHMCS friends, so I started to customize my WHMCS after a few years again and logically missed the points when the developers switched to using hooks. Now, it's being a nightmare for me (maybe for others as well) to make some little changes to the code. But ok, my current problem is: I wan't the sidebar menu with product categories to be visible on all other pages like: /announcements.php /knowledgebase.php /serverstatus.php (if not-logged-in as well) /contact.php and in all other new created pages I want it add too. Please see the screenshots. Thanks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 14, 2017 Share Posted March 14, 2017 so I started to customize my WHMCS after a few years again and logically missed the points when the developers switched to using hooks. Now, it's being a nightmare for me (maybe for others as well) to make some little changes to the code. But ok, my current problem is: I want the sidebar menu with product categories to be visible on all other pages like: /announcements.php /knowledgebase.php /serverstatus.php (if not-logged-in as well) /contact.php and in all other new created pages I want it add too. you could do that with an action hook that checks if the Categories sidebar exists on the page - if so, it doesn't do anything; if it's missing, it recreates it. similarly for the actions sidebar - except you wouldn't need to query the database for that, you'd just recreate the sidebar and it's 4 children (renewals, register, transfer, view cart) directly in the hook. Please see the screenshots. FWIW - do you really think that's a good idea? take a look at your knowledgebase page - you've got 4 sidebars already there (including the long categories sidebar) - and you want to add 3 more sidebars to the page? don't get me wrong, you can do it - but if i'm at your kb page, do I need to see a list of your product categories, register a domain or even change currency - I wouldn't have thought so... and the same would go for the other pages you list too. 0 Quote Link to comment Share on other sites More sharing options...
isixhosting Posted March 14, 2017 Author Share Posted March 14, 2017 you could do that with an action hook that checks if the Categories sidebar exists on the page - if so, it doesn't do anything; if it's missing, it recreates it.similarly for the actions sidebar - except you wouldn't need to query the database for that, you'd just recreate the sidebar and it's 4 children (renewals, register, transfer, view cart) directly in the hook. FWIW - do you really think that's a good idea? take a look at your knowledgebase page - you've got 4 sidebars already there (including the long categories sidebar) - and you want to add 3 more sidebars to the page? don't get me wrong, you can do it - but if i'm at your kb page, do I need to see a list of your product categories, register a domain or even change currency - I wouldn't have thought so... and the same would go for the other pages you list too. Thanks Brian. Yeah, you're right about the KB... But I would like to add it to the other pages. Can you please provide me with the hook source code and where do I have to it in? Many thanks. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 14, 2017 Share Posted March 14, 2017 for the product groups (categories) sidebar, it's the only one that's going to need a query to the database - create a new .php file in /includes/hooks and add the following... <?php use WHMCS\View\Menu\Item as MenuItem; use Illuminate\Database\Capsule\Manager as Capsule; add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) { if (is_null($secondarySidebar->getChild('Categories'))) { $ProductGroups = Capsule::table('tblproductgroups') ->where('tblproductgroups.hidden', '0') ->select('order', 'id', 'name') ->get(); $secondarySidebar->addChild('Product Groups', array( 'label' => Lang::trans('ordercategories'), )); foreach ($ProductGroups as $child){ $secondarySidebar->getChild('Product Groups') ->addChild($child->name, array( 'label' => $child->name, 'uri' => 'cart.php?gid='.$child->id, 'order' => $child->order, )); } $secondarySidebar->getChild('Product Groups') ->addChild('Product Addons', array( 'label' => Lang::trans('cartproductaddons'), 'uri' => 'cart.php?gid=addons', 'order' => 1000, )); } }); as I said previously, the actions sidebar can just be created in another hook as a parent, with 4 children - the currency sidebar is a pain to recreate if memory serves, so i'd leave that if I were you. 1 Quote Link to comment Share on other sites More sharing options...
isixhosting Posted March 14, 2017 Author Share Posted March 14, 2017 Works perfectly. 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.