Silentsushix3 Posted October 2, 2016 Share Posted October 2, 2016 For my Whmcs site, I am working on the homepage. I was able to move a few things I wanted on to it. Except when I try to get client product/services details so people could instantly click into their active products, it just says "no records found". I understand WHMCS does not pass the required information on to that page. But I am not the greatest with PHP and am unable to get this working. Could anyone point me in the right direction or help me with this. The products/services table in the below image is what I am working on. It is the same as the clientarea product details page. Thanks in advanced for any help! - - - Updated - - - Sorry, I put the wrong title, hopefully not to confusing. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 2, 2016 Share Posted October 2, 2016 For my Whmcs site, I am working on the homepage. I was able to move a few things I wanted on to it. Except when I try to get client product/services details so people could instantly click into their active products, it just says "no records found". I understand WHMCS does not pass the required information on to that page. But I am not the greatest with PHP and am unable to get this working. Could anyone point me in the right direction or help me with this. the short answer is that adding {debug} to the end of a Smarty template, e.g homepage.tpl, will tell you what Smarty variables and arrays the page has access to. The products/services table in the below image is what I am working on. It is the same as the clientarea product details page.. the long answer is because you don't have access to the required array, you can't simply copy & paste template code from one template into another and expect it to work. therefore, you'll need to query the database, using an action hook, to recreate the $services array - if you could do that, then the output would work... and if you're thinking of showing domains in a similar way, that would require another hook. looking at the output, it may be querying 4 or more database tables to create that array... though you might not actually need to query all of them depending on what information you want to show. 0 Quote Link to comment Share on other sites More sharing options...
Silentsushix3 Posted October 2, 2016 Author Share Posted October 2, 2016 the short answer is that adding {debug} to the end of a Smarty template, e.g homepage.tpl, will tell you what Smarty variables and arrays the page has access to. the long answer is because you don't have access to the required array, you can't simply copy & paste template code from one template into another and expect it to work. therefore, you'll need to query the database, using an action hook, to recreate the $services array - if you could do that, then the output would work... and if you're thinking of showing domains in a similar way, that would require another hook. looking at the output, it may be querying 4 or more database tables to create that array... though you might not actually need to query all of them depending on what information you want to show. But, could you possibly show me some basic query php code that I might be able to tear apart and learn from so I could have a good foot to stand on when trying to code the php array. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 3, 2016 Share Posted October 3, 2016 But, could you possibly show me some basic query php code that I might be able to tear apart and learn from so I could have a good foot to stand on when trying to code the php array. ok, here's the starting point for your hook - i'm assuming it's going to be on the client's homepage once they've logged in... if you create a file in /includes/hooks/ and call it 'productslist.php' and then paste the code below into it... <?php use Illuminate\Database\Capsule\Manager as Capsule; function products_list_hook($vars) { $client = Menu::context('client'); $services = Capsule::table('tblhosting') ->join('tblproducts','tblhosting.packageid','=','tblproducts.id') ->where('userid',$client->id) ->select('tblhosting.*','tblproducts.name as product') ->get(); $encodedata = json_encode($services); $decodedata = json_decode($encodedata, true); return array("services" => $decodedata); } add_hook("ClientAreaPageHome", 1, "products_list_hook"); ?> ... you should get a near working services table on the homepage... you'll possibly need to make a couple of changes to the template Smarty code or to the hook... e.g to get the status code working, you'd need to change... <td class="text-center"><span class="label status status-{$service.status|strtolower}">{$service.statustext}</span></td> to... <td class="text-center"><span class="label status status-{$service.domainstatus|strtolower}">{$service.domainstatus}</span></td> you could also tweak the date format in Smarty, though you may then run into issues when sorting... and wrap the pricing in the client's currency. 0 Quote Link to comment Share on other sites More sharing options...
Silentsushix3 Posted October 5, 2016 Author Share Posted October 5, 2016 Thanks for your reply, I will go over the code and your post in-depth tomorrow and try it our. Thank you for your help. Been going 2 days straight working on learning Smarty a little first, then realizing how big of a task I had in front of me! 0 Quote Link to comment Share on other sites More sharing options...
Silentsushix3 Posted October 30, 2016 Author Share Posted October 30, 2016 Had to take some time off. Just got back, and still no luck getting the services table on to homepage.tpl https://gyazo.com/2faa625ea5c95aa299e1915914778253 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted October 31, 2016 Share Posted October 31, 2016 Had to take some time off. Just got back, and still no luck getting the services table on to homepage.tpl you could try one of two things (or both!) 1. try changing the "services" array name to something else... return array("services2" => $decodedata); and then change the code in the template to use $services2... 2. add {debug} to the end of the homepage.tpl template to see if the array exists and what it contains - that might give a clue as to where the error is. there are errors in your homepage.tpl code, but none that I think should be causing this... in fact, i've re-tested the hook on v7.0.1 and it works fine locally... 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.