Jump to content

Show product groups to homepage.tpl


biaprot

Recommended Posts

Hello !

I am having a problem on Product Groups show on homepage.tpl .

I use this code but missing tblproductgroups :)

 

{php}
$userid = $this->_tpl_vars['clientsdetails']['id'];
$result = mysql_query("SELECT * FROM tblhosting,tblproducts WHERE userid =$userid AND tblhosting.packageid= tblproducts.id");
$services = array();
while ($data = mysql_fetch_array($result)) {
array_push($services, $data);
}
$this->_tpl_vars['services'] = $services;
{/php}

 

From this Topic : http://forum.whmcs.com/showthread.php?48409-Customise-clientarea-tpl-to-display-Active-Products-Services

 

Like this :

 

1.png

 

2.png

 

Anyone can help me , thanks

Link to comment
Share on other sites

there are at least three problems with this...

 

1. using code posted from 2-3 years ago, isn't ideal!

2. using {php} tags in the template will, at some point, be disabled.

3. $this->_tpl_vars has been changed.

 

for 3, read the documentation below...

 

http://docs.whmcs.com/Version_6_Template_Migration_Guide#.7Bphp.7D_Block_Syntax

 

for the SQL query, you could try...

 

SELECT * FROM tblhosting,tblproducts,tblproductgroups WHERE userid = $userid AND tblhosting.packageid = tblproducts.id and tblproductgroups.id = tblproducts.gid

it's not very efficient, but it will give you the product group name.

Link to comment
Share on other sites

Hello ! i try but not working :)

i'm not surprised. :)

 

if I were you, I wouldn't waste any time trying to fix this - even if you could get it to work now, it will fail as soon as WHMCS disable {php} tags.

 

there would be two better ways to do this - either use an action hook to create the required variables and pass them to the modified homepage template, or use a Data Feed to embed the output you want.

 

if you're new to either solution, the data feed option would probably be the simplest - the core part of both is the SQL query, and you already have that.

 

take a look at some of the existing data feeds in the 'feeds' directory, and you should see how they work.

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