Jump to content

What info is passed from clientarea to homepage


Recommended Posts

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.

 

ad53c65d5a8df69a713cc8712f86c0b0.png

 

Thanks in advanced for any help!

 

- - - Updated - - -

 

Sorry, I put the wrong title, hopefully not to confusing.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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... :idea:

BBGrW54.png

 

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. :idea:

Link to comment
Share on other sites

  • 4 weeks later...
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...

 

bpmrawd.png

3W7uJGM.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated