Tapeix Posted November 20, 2015 Share Posted November 20, 2015 (edited) Ok guys, I have created a hook (based on WHMCS given examples) and finally created a new widget in WHMCS brand new sidebar, yay! However, this widgets needs to be activated when users are logged in; not when guests are visiting my WHMCS installation, so I added: App::getCurrentFilename() == 'clientarea'. Unfortunately, this is far from perfect, since the widget is also being displayed at the login page. Of course, I can remove with a little .css styling, but even when I do this, the widget isn't displayed on the network status page or the knowledgebase. <?php use WHMCS\View\Menu\Item as MenuItem; $client = Menu::context('client'); if(App::getCurrentFilename() == 'clientarea' && $_SESSION['Language']!="english") add_hook('ClientAreaSecondarySidebar', 1, function (MenuItem $secondarySidebar) { $secondarySidebar->addChild('shortcuts', array( 'label' => 'Useful shortcuts', 'uri' => '#', 'icon' => 'fa-question-circle', )); Does anyone have a better option? Thanks! Edited November 20, 2015 by Tapeix 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 20, 2015 Share Posted November 20, 2015 oh don't call them widgets, i'll get confused! widgets are in the admin area, these are sidebars.... you almost had it - you need to check the value of $client to see if they're logged in or not... if they're not logged in (a guest), the variable won't exist... if they are, it will... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { $client = Menu::context('client'); if (!is_null($client)) { $secondarySidebar->addChild('shortcuts', array( 'label' => 'Useful shortcuts', 'uri' => '#', 'icon' => 'fa-question-circle')); } }); with regards to language, because this hook only applies to clients, you could use $client->language to check - but if you're trying to make the sidebar multilingual, there are better methods. 1 Quote Link to comment Share on other sites More sharing options...
Tapeix Posted November 20, 2015 Author Share Posted November 20, 2015 (edited) Thanks Brian! This is what my php code looks like now. Works like a charm. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { $client = Menu::context('client') ; if (!is_null($client) && $_SESSION['Language']!="english") { $secondarySidebar->addChild('shortcuts', array( 'label' => 'Shortcuts', 'uri' => '#', 'icon' => 'fa-question-circle')); $ShortcutsPanel = $secondarySidebar->getChild('shortcuts'); $ShortcutsPanel->moveToBack(); $ShortcutsPanel->addChild('smssettings', array( 'uri' => '#', 'label' => 'SMS settings', 'order' => 1, 'icon' => 'fa-mobile')); } }); Edited November 20, 2015 by Tapeix 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 20, 2015 Share Posted November 20, 2015 (edited) if you wanted to, you could trim that code a little... <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { $client = Menu::context('client') ; if (!is_null($client) && $_SESSION['Language']!="english") { $secondarySidebar->addChild('shortcuts', array( 'label' => 'Shortcuts', 'uri' => '#', 'icon' => 'fa-question-circle')) ->moveToBack(); $secondarySidebar->addChild('smssettings', array( 'uri' => '#', 'label' => 'SMS settings', 'order' => 1, 'icon' => 'fa-mobile')); } }); it's probably also worth adding that I don't think $_SESSION['Language'] exists when you first visit the site, unless the language has been specified, either in the URL or by clicking a language link - only then will it available to be used in the way you want to. Edited November 21, 2015 by brian! 0 Quote Link to comment Share on other sites More sharing options...
Tapeix Posted November 22, 2015 Author Share Posted November 22, 2015 Okidoki! I have no idea how to force language. Maybe if I add: !is_null(['Language']!="english")) ...but I don't think this would work. @Brian!, could you please help me with the link below? I'm looking for a solution to integrate Gravity Forms (Wordpress) with WHMCS for over a year. I try to export data from Gravity Forms to WHMCS (e.g. adding clients in WHMCS with the given information by Gravity Forms). With the release of WHMCSv6, I try to find someone again. >> http://forums.whmcs.com/showthread.php?108734-API-doesn-t-work 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 22, 2015 Share Posted November 22, 2015 Okidoki! I have no idea how to force language. Maybe if I add: !is_null(['Language']!="english")) ...but I don't think this would work. the easiest way to force a language would be to add it to the URL... but you shouldn't really need to for this hook. as you want this hook to only work for logged-in clients, you can get their default language from existing variables without the need for session variables... if they change their language while logged in, it changes their default language to that - so the variable should always exist. <?php use WHMCS\View\Menu\Item as MenuItem; add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar) { $client = Menu::context('client'); if (!is_null($client) && ($client->language !="english")) { $secondarySidebar->addChild('shortcuts', array( 'label' => 'Shortcuts', 'uri' => '#', 'icon' => 'fa-question-circle')) ->moveToBack(); $secondarySidebar->addChild('smssettings', array( 'uri' => '#', 'label' => 'SMS settings', 'order' => 1, 'icon' => 'fa-mobile')); } }); @Brian!, could you please help me with the link below? I'm looking for a solution to integrate Gravity Forms (Wordpress) with WHMCS for over a year. I try to export data from Gravity Forms to WHMCS (e.g. adding clients in WHMCS with the given information by Gravity Forms). With the release of WHMCSv6, I try to find someone again. >> http://forums.whmcs.com/showthread.php?108734-API-doesn-t-work i'm not reading any API manuals on a Sunday afternoon! posting in Marketplace and requesting quotes is probably a better option to find a solution for this. 0 Quote Link to comment Share on other sites More sharing options...
Tapeix Posted November 22, 2015 Author Share Posted November 22, 2015 Thank you so much Brian! 0 Quote Link to comment Share on other sites More sharing options...
Tapeix Posted December 21, 2015 Author Share Posted December 21, 2015 Hmm, I need to hide this hook when a user is in /clientarea.php?action=productdetails. How can I do this? This is what it looks when I am navigating in my product details for example... not what it ment to be. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted December 21, 2015 Share Posted December 21, 2015 Hmm, I need to hide this hook when a user is in /clientarea.php?action=productdetails. How can I do this? This is what it looks when I am navigating in my product details for example... not what it ment to be. [ATTACH=CONFIG]9834[/ATTACH][ATTACH=CONFIG]9835[/ATTACH] this issue could be fixed without hiding your sidebar http://forum.whmcs.com/showthread.php?106891-Display-Credit-Balance-In-Six-Template&p=448314#post448314 0 Quote Link to comment Share on other sites More sharing options...
Tapeix Posted December 22, 2015 Author Share Posted December 22, 2015 this issue could be fixed without hiding your sidebarhttp://forum.whmcs.com/showthread.php?106891-Display-Credit-Balance-In-Six-Template&p=448314#post448314 Thank you so much! 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.