TGK Posted August 12, 2018 Share Posted August 12, 2018 Hi there is possible add a client area homepage panel that show a custom client field? i dont know how call it exactly maybe some can help me thanks add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels) { $client = Menu::context( "client" ); $clientid = intval( $client->id ); { $bodyhtml = ; $examplePanel = $homePagePanels->addChild( 'Example', array( 'label' => Lang::trans('example'), 'icon' => 'fa-example', 'extras' => array( 'color' => 'red', 'btn-link' => '#', 'btn-text' => Lang::trans('example'), 'btn-icon' => 'fa-plus', ), 'bodyHtml' => $bodyhtml )); } }); 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted August 12, 2018 Share Posted August 12, 2018 Just add a query in your action hook to retrieve the specific client custom field you need. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 12, 2018 Share Posted August 12, 2018 14 hours ago, TGK said: Hi there is possible add a client area homepage panel that show a custom client field? i don't know how call it exactly maybe some can help me. there would be the usual three ways... take it from Smarty variables - you know that they'll be logged in, therefore you can access the $clientsdetails array and get the value from there. query the database... again, you know they'll be logged in so you can get their ID, and if you know the CCF you are looking for, with that info you can query the db to get the value. use the Class Docs to get the array... of the 3, i'd use 2 as the most accurate - especially if you're only getting one CCF value. ultimately, getting a customfield value is a navbar/sidebar or homepagepanel are all the same methods - only the hook names, and the output method varies slightly... so to take your example hook, and add a DB query for a specific client customfield (e.g Account Manager), you could do this... <?php use WHMCS\View\Menu\Item; use Illuminate\Database\Capsule\Manager as Capsule; add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels) { $client = Menu::context( "client" ); $fieldid = Capsule::table('tblcustomfields')->where('fieldname', 'Account Manager')->where('type', 'client')->value('id'); $fieldvalue = Capsule::table('tblcustomfieldsvalues')->where('fieldid', $fieldid)->where('relid', $client->id)->value('value'); $bodyhtml = '<p>Your Account Manager is '.$fieldvalue.'.</p>'; $examplePanel = $homePagePanels->addChild( 'Example', array( 'label' => Lang::trans('example'), 'icon' => 'fa-example', 'extras' => array( 'color' => 'red', 'btn-link' => '#', 'btn-text' => Lang::trans('example'), 'btn-icon' => 'fa-plus', ), 'bodyHtml' => $bodyhtml )); }); 0 Quote Link to comment Share on other sites More sharing options...
TGK Posted August 12, 2018 Author Share Posted August 12, 2018 thanks everyone, works fine!! but i change 'icon' => 'fa-example', to 'icon' => 'fa-money', but the icon doesnt show i dont know why 0 Quote Link to comment Share on other sites More sharing options...
TGK Posted August 12, 2018 Author Share Posted August 12, 2018 its ok now thanks all !! 0 Quote Link to comment Share on other sites More sharing options...
TGK Posted August 12, 2018 Author Share Posted August 12, 2018 7 hours ago, brian! said: there would be the usual three ways... take it from Smarty variables - you know that they'll be logged in, therefore you can access the $clientsdetails array and get the value from there. query the database... again, you know they'll be logged in so you can get their ID, and if you know the CCF you are looking for, with that info you can query the db to get the value. use the Class Docs to get the array... of the 3, i'd use 2 as the most accurate - especially if you're only getting one CCF value. ultimately, getting a customfield value is a navbar/sidebar or homepagepanel are all the same methods - only the hook names, and the output method varies slightly... so to take your example hook, and add a DB query for a specific client customfield (e.g Account Manager), you could do this... <?php use WHMCS\View\Menu\Item; use Illuminate\Database\Capsule\Manager as Capsule; add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels) { $client = Menu::context( "client" ); $fieldid = Capsule::table('tblcustomfields')->where('fieldname', 'Account Manager')->where('type', 'client')->value('id'); $fieldvalue = Capsule::table('tblcustomfieldsvalues')->where('fieldid', $fieldid)->where('relid', $client->id)->value('value'); $bodyhtml = '<p>Your Account Manager is '.$fieldvalue.'.</p>'; $examplePanel = $homePagePanels->addChild( 'Example', array( 'label' => Lang::trans('example'), 'icon' => 'fa-example', 'extras' => array( 'color' => 'red', 'btn-link' => '#', 'btn-text' => Lang::trans('example'), 'btn-icon' => 'fa-plus', ), 'bodyHtml' => $bodyhtml )); }); code works fine Brian maybe you can help me a bit i want show panel only if custom field info exists, please ill apreciate it 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 13, 2018 Share Posted August 13, 2018 11 hours ago, TGK said: code works fine Brian maybe you can help me a bit i want show panel only if custom field info exists, just wrap the output in an if statement that checks whether that final db query got a result. <?php use WHMCS\View\Menu\Item; use Illuminate\Database\Capsule\Manager as Capsule; add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels) { $client = Menu::context( "client" ); $fieldid = Capsule::table('tblcustomfields')->where('fieldname', 'Account Manager')->where('type', 'client')->value('id'); $fieldvalue = Capsule::table('tblcustomfieldsvalues')->where('fieldid', $fieldid)->where('relid', $client->id)->value('value'); if ($fieldvalue) { $bodyhtml = '<p>Your Account Manager is '.$fieldvalue.'.</p>'; $examplePanel = $homePagePanels->addChild( 'Example', array( 'label' => Lang::trans('example'), 'icon' => 'fa-money-bill', 'extras' => array( 'color' => 'red', 'btn-link' => '#', 'btn-text' => Lang::trans('example'), 'btn-icon' => 'fa-plus', ), 'bodyHtml' => $bodyhtml )); } }); 16 hours ago, TGK said: 'icon' => 'fa-example', to 'icon' => 'fa-money', but the icon doesn't show i dont know why fa-example and fa-money aren't existing FontAwesome Icons - you would need to choose one from FA5 is using WHMCS v7.6.. there are bugs with FA5 in v7.6, but it's unlikely you'll come across them (though I just found another answering this thread!). 😀 0 Quote Link to comment Share on other sites More sharing options...
TGK Posted August 13, 2018 Author Share Posted August 13, 2018 maybe im doing something wrong if i put a "if " all panels didnt show the code stop work My fieldname is Banesco <?php use WHMCS\View\Menu\Item; use Illuminate\Database\Capsule\Manager as Capsule; add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels) { $client = Menu::context( "client" ); $fieldid = Capsule::table('tblcustomfields')->where('fieldname', 'Banesco')->where('type', 'client')->value('id'); $fieldvalue = Capsule::table('tblcustomfieldsvalues')->where('fieldid', $fieldid)->where('relid', $client->id)->value('value'); if ($fieldvalue) { $bodyhtml = '<p>Numero de Cuenta: '.$fieldvalue.'</p>'; $cuentabancariaPanel = $homePagePanels->addChild( 'Cuenta BancariaV', array( 'label' => 'Cuenta Bancaria <img src="https://www.com/notoch99/wp-content/uploads/2018/08/ven.png" width="20" height="20 ">', 'icon' => 'fa-bank', 'extras' => array( 'color' => 'green', 'btn-link' => 'https://com/clientarea.php?action=details', 'btn-text' => 'Agregar', 'btn-icon' => 'fa-plus', ), 'bodyHtml' => $bodyhtml, )); } }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 13, 2018 Share Posted August 13, 2018 23 minutes ago, TGK said: maybe im doing something wrong if i put a "if " all panels didnt show the code stop work there is something wrong with you code, as it's causing an error message.. Quote exception 'Whoops\Exception\ErrorException' with message 'syntax error, unexpected '$bodyhtml' try the following, it's working fine for me on v7.6 - though don't forget to change the image path in the labe; you don't need to add your domain to the btn-link URL.. and I don't think 'fa-bank' is a valid fontawesome icon. <?php use WHMCS\View\Menu\Item; use Illuminate\Database\Capsule\Manager as Capsule; add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels) { $client = Menu::context( "client" ); $fieldid = Capsule::table('tblcustomfields')->where('fieldname', 'Banesco')->where('type', 'client')->value('id'); $fieldvalue = Capsule::table('tblcustomfieldsvalues')->where('fieldid', $fieldid)->where('relid', $client->id)->value('value'); if ($fieldvalue) { $bodyhtml = '<p>Numero de Cuenta: '.$fieldvalue.'.</p>'; $homePagePanels->addChild( 'Example', array( 'label' => 'Cuenta Bancaria <img src="https://www.com/notoch99/wp-content/uploads/2018/08/ven.png" width="20" height="20 ">', 'icon' => 'fa-bank', 'extras' => array( 'color' => 'green', 'btn-link' => 'clientarea.php?action=details', 'btn-text' => 'Agregar', 'btn-icon' => 'fa-plus', ), 'bodyHtml' => $bodyhtml )); } }); 0 Quote Link to comment Share on other sites More sharing options...
TGK Posted August 13, 2018 Author Share Posted August 13, 2018 i leave image panel is show fine problem is when i put the " IF " panel dissapear fa-bank works fine thanks for your help i apreciate it im using 7.5.2 atm cant update because somes modules not compatible yet 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 13, 2018 Share Posted August 13, 2018 if the IF statement is the problem, then the only way it wouldn't show the panel would be if the second database query was empty - you could try using the IF statement below instead... if (!empty($fieldvalue)) { 0 Quote Link to comment Share on other sites More sharing options...
TGK Posted August 13, 2018 Author Share Posted August 13, 2018 Works fine, great! thanks! Brian! again. 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.