Anders Posted March 16, 2020 Share Posted March 16, 2020 Hi guys, i am trying to add a button in clientareaproductdetails please see screenshot. i tried in mytheme/clientareaproductdetails.tpl also tried in \modules\servers\cpanel\templates/overview.tpl i cleared cache but nothing showing up. this is in overview.tpl on line 14 i added this but is not working, i did he same in /clientareaproductdetails.tpl any ideas? <!--<a href="http://{$domain}" class="btn btn-default btn-sm" target="_blank">{$LANG.visitwebsite}</a>--> <a href="myownurl" class="btn btn-default btn-sm" target="_blank">{$LANG.mylang}</a> <div class="col-md-6"> <div class="panel panel-default" id="cPanelPackagePanel"> <div class="panel-heading"> <h3 class="panel-title">{$LANG.cPanel.packageDomain}</h3> </div> <div class="panel-body text-center"> <div class="cpanel-package-details"> <em>{$groupname}</em> <h4 style="margin:0;">{$product}</h4> <a href="http://{$domain}" target="_blank">www.{$domain}</a> </div> <p> <!--<a href="http://{$domain}" class="btn btn-default btn-sm" target="_blank">{$LANG.visitwebsite}</a>--> <a href="myownurl" class="btn btn-default btn-sm" target="_blank">{$LANG.mylang}</a> {if $domainId} <a href="clientarea.php?action=domaindetails&id={$domainId}" class="btn btn-success btn-sm" target="_blank">{$LANG.managedomain}</a> {/if} <input type="button" onclick="popupWindow('whois.php?domain={$domain}','whois',650,420);return false;" value="{$LANG.whoisinfo}" class="btn btn-info btn-sm" /> </p> </div> </div> {if $availableAddonProducts} <div class="panel panel-default" id="cPanelExtrasPurchasePanel"> <div class="panel-heading"> <h3 class="panel-title">{$LANG.cPanel.addonsExtras}</h3> </div> <div class="panel-body text-center"> <form method="post" action="cart.php?a=add" class="form-inline"> <input type="hidden" name="serviceid" value="{$serviceid}" /> <select name="aid" class="form-control input-sm"> {foreach $availableAddonProducts as $addonId => $addonName} <option value="{$addonId}">{$addonName}</option> {/foreach} </select> <button type="submit" class="btn btn-default btn-sm"> <i class="fas fa-shopping-cart"></i> {$LANG.cPanel.purchaseActivate} </button> </form> </div> </div> {/if} </div> 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 17, 2020 Share Posted March 17, 2020 15 hours ago, Anders said: this is in overview.tpl on line 14 i added this but is not working, i did he same in /clientareaproductdetails.tpl any ideas? if it's a cPanel product, then it shopuld be the overview template; if it's using another module, then there may be separate templates available - otherwise, it would be clientareaproductdetails.tpl. for example, if I tweak overview.tpl to add another button, and I view a cPanel service in productdetails, I see this... <p> <a href="http://{$domain}" class="btn btn-default btn-sm" target="_blank">{$LANG.visitwebsite}</a> <a href="myownurl" class="btn btn-default btn-sm" target="_blank">Button</a> {if $domainId} <a href="clientarea.php?action=domaindetails&id={$domainId}" class="btn btn-success btn-sm" target="_blank">{$LANG.managedomain}</a> {/if} <input type="button" onclick="popupWindow('whois.php?domain={$domain}','whois',650,420);return false;" value="{$LANG.whoisinfo}" class="btn btn-info btn-sm" /> </p> ignore that i've hardcoded the button text rather than using a Language string, but it was quicker... also, you shouldn't really edit overview.tpl as it will get overwritten during a WHMCS update - you can copy the template(s) to your active template folder and they shouldn't (theoretically!) get overwritten - though you'd have to remember to check after an update to see if they've been any template changes. https://docs.whmcs.com/Working_with_Module_Templates Quote For example, in the case of the provisioning module "cpanel", /modules/servers/cpanel/overview.tpl could be customised by creating the following template file: /templates/yourtemplatename/modules/servers/cpanel/overview.tpl you could inject a button into there with a hook, but then it gets real complicated if you wanted to also remove an existing button - especially as WHMCS has an aversion to correct CSS use in it's code. so it's easier to stick with editing these templates for now! 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted March 17, 2020 Author Share Posted March 17, 2020 Thx again for your advice :) i made a folder in template file see screenshot and i have added the code and still no show of the button, any ideas? <p> <a href="http://{$domain}" class="btn btn-default btn-sm" target="_blank">{$LANG.visitwebsite}</a> <a href="index.php?m=websitebuilder" target="_blank">WEBSITEBUILDER</a> {if $domainId} <a href="clientarea.php?action=domaindetails&id={$domainId}" class="btn btn-success btn-sm" target="_blank">{$LANG.managedomain}</a> {/if} <input type="button" onclick="popupWindow('whois.php?domain={$domain}','whois',650,420);return false;" value="{$LANG.whoisinfo}" class="btn btn-info btn-sm" /> </p> 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 17, 2020 Share Posted March 17, 2020 1 hour ago, Anders said: i made a folder in template file see screenshot and i have added the code and still no show of the button, any ideas? are you 100% sure that it's a cPanel service using the default cPanel module ?? 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted March 17, 2020 Author Share Posted March 17, 2020 oh i see is a module installed called panel extended. is it not possible to add a button with that module? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 17, 2020 Share Posted March 17, 2020 6 minutes ago, Anders said: oh i see is a module installed called panel extended. by ModuleGardens ? 6 minutes ago, Anders said: is it not possible to add a button with that module? I assume there is a /templates folder with the /modules/servers/cpanelExtended/ folder ? if so, then there must be a similar template in there. as I said, you could do it with a hook, but it might be worth asking MG about editing the template and the implications of what happens if you update their module. 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted March 17, 2020 Author Share Posted March 17, 2020 thx Brian i found it :) 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted March 30, 2020 Author Share Posted March 30, 2020 Hello Brian, i am using your amazing hook see below but for some reason it does not add my text button on ID 4 it add it on all the others as you also can see i use ID 4 a copy from my whmcs (https://mysite.com/whmcs/cart.php?a=add&pid=4) any ideas is so weird <?php add_hook('ClientAreaProductDetailsOutput', 1, function($service) { $serviceID = $service['service']->Id; $productID = $service['service']->packageId; $groupID = $service['service']->product->productGroupId; if (in_array($productID, array('2','3','4'))) { $output .= '<div class="alert" role="alert"><div class="row"><div class="col-sm-1"></div> <div class="text-center"><a type="button" href="index.php?m=stiew12" style="padding: 5px 40px; color:#fff;" class="btn btn-primary btn-lg" target="_blank"><i class="fa fa-pencil" aria-hidden="true"></i> site</a></div></div></div>'; } if ($output) { return $output; } }); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 30, 2020 Share Posted March 30, 2020 is there anything different about product #4 compared with 2 or 3 ?? e.g is it a different product type, user another module etc ?? 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted March 30, 2020 Author Share Posted March 30, 2020 brian sorry, it was a difference in features, client area template settings in module of cpanle extended. is all good now :) 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted May 3, 2020 Author Share Posted May 3, 2020 Hi Brian, i wonder if you could help me with this as you are the super pro :) i use this code below in user area but i wish to disable it for a groupID (2)and productID (5) add_hook('ClientAreaHomepage', 1, function($vars) { $client = Menu::context('client'); $activeservices = $client->services->where('domainstatus','=','Active')->count(); if ($client && $activeservices == 0) { return '<div class="text-center"><h3 class="alert alert-info order-confirmation"><a href="#myModal" data-toggle="modal"><strong><i class="fab fa-youtube" aria-hidden="true"> Watch how to get to Website Builder</i></strong></a></h3></div><br /> <!-- Modal HTML --> <div id="myModal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">How to find builder</h4> </div> <div class="modal-body"> <iframe id="cartoonVideo" width="560" height="315" src="#" frameborder="0" allowfullscreen></iframe> </div> </div> </div> </div>'; } }); warm regards Anders 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 3, 2020 Share Posted May 3, 2020 4 hours ago, Anders said: i use this code below in user area but i wish to disable it for a groupID (2)and productID (5) product groups are a problem because the model (and by implication the database table) don't store them... so what you will have to do is get a list of product IDs for that group and then use that list in the conditional statement... because there was a technical issue using wherenotin (don't know if that's a bug), I switched to using capsule and querying the database. <?php use WHMCS\Database\Capsule; add_hook('ClientAreaHomepage', 1, function($vars) { $client = Menu::context('client'); $groupproducts = Capsule::table('tblproducts')->where('gid','2')->pluck('id'); $activeservices = Capsule::table('tblhosting')->where('userid',$client->id)->where('domainstatus','Active')->where('packageid','<>','5')->whereNotIn('packageid',$groupproducts)->count(); if ($client && $activeservices == 0) { return '<div class="text-center"><h3 class="alert alert-info order-confirmation"><a href="#myModal" data-toggle="modal"><strong><i class="fab fa-youtube" aria-hidden="true"> Watch how to get to Website Builder</i></strong></a></h3></div><br /> <!-- Modal HTML --> <div id="myModal" class="modal fade"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">How to find builder</h4> </div> <div class="modal-body"> <iframe id="cartoonVideo" width="560" height="315" src="#" frameborder="0" allowfullscreen></iframe> </div> </div> </div> </div>'; ; } }); 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted May 4, 2020 Author Share Posted May 4, 2020 hello Brian, it did not work, it disable the button for Group 1 and product 4 also. Any ideas? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 4, 2020 Share Posted May 4, 2020 22 minutes ago, Anders said: it did not work, it disable the button for Group 1 and product 4 also. quick question - when you said groupid, you did mean product groups and not client groups didn't you ? 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted May 4, 2020 Author Share Posted May 4, 2020 product groups is the gid=2 and in ther is the pid=5 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 4, 2020 Share Posted May 4, 2020 how many products are in gid #2 ? 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted May 4, 2020 Author Share Posted May 4, 2020 one for the moment 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 4, 2020 Share Posted May 4, 2020 2 minutes ago, Anders said: one for the moment then what happens if you use... $activeservices = Capsule::table('tblhosting')->where('userid',$client->id)->where('domainstatus','Active')->whereNotIn('packageid',[5,x])->count(); change x to the PID of the product in #2 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted May 4, 2020 Author Share Posted May 4, 2020 $activeservices = Capsule::table('tblhosting')->where('userid',$client->id)->where('domainstatus','Active')->whereNotIn('packageid',[5,2])->count() should i add a number 2 in the x? like above 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 4, 2020 Share Posted May 4, 2020 1 minute ago, Anders said: should i add a number 2 in the x? like above add the pid value of the product in group #2 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted May 4, 2020 Author Share Posted May 4, 2020 i am confused. the product group is 2 and the product is 5 should be like this then ('packageid',[5,2]) 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 4, 2020 Share Posted May 4, 2020 1 minute ago, Anders said: i am confused. join the club. 😕 1 minute ago, Anders said: the product group is 2 and the product is 5 but what is the one product in group #2 ? is it pid #5 or another product ? 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted May 4, 2020 Author Share Posted May 4, 2020 lol 🙂 and sorry for not explaining good yes pid # 5 is the product Direct Shopping Cart Link https://mysite.com/whmcs/cart.php?a=add&pid=5 Product Group Cart Link https://mysite.com/whmcs/cart.php?gid=2 0 Quote Link to comment Share on other sites More sharing options...
Anders Posted May 4, 2020 Author Share Posted May 4, 2020 oh i see i did not understand. i have product group Gid #1 also and there i have Pid # 1,2,3,4 i wanted only to disable (prduct) pid=5 in (product group)gid=2 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted May 4, 2020 Share Posted May 4, 2020 then for now, you won't have to check gid #2... $activeservices = Capsule::table('tblhosting')->where('userid',$client->id)->where('domainstatus','Active')->where('packageid','<>','5')->count(); 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.