regrettably Posted May 21, 2010 Share Posted May 21, 2010 Hey everyone, I'm trying to create a few new pages in WHMCS (http://wiki.whmcs.com/Creating_Pages) and what I would like to do is display some client product details. For example I would like to display clients assigned IPs and hostname when they visit mydomain.com/whmcs/newpage.php. Unfortunately WHMCS doesn't seem to pick up product details outside of clientareaproductdetails.tpl and clientareaproducts.tpl. Is there a way for me to display clients hostname, IPs aswell as other product details outside of the clientareaproductdetails.tpl template? Thanks in advance! 0 Quote Link to comment Share on other sites More sharing options...
bhavicp Posted May 22, 2010 Share Posted May 22, 2010 I also was wondering if theres a better way to get clients details instead of searching in the MySQL DB yourself. As i need to get some custom-field values but it proves difficult as it's not like "Product field value" but i have to go through multiple tables to get the right value for the right product. 0 Quote Link to comment Share on other sites More sharing options...
tomdchi Posted May 23, 2010 Share Posted May 23, 2010 Making a custom page allows you to retrieve any info and display it however you want. That requires php and smarty template knowledge though. http://wiki.whmcs.com/Creating_Pages is showing you how to make a new php file to use in the client area. You are going to need to create queries to the database to get the info you want. make a new template and put in the templates folder, or just copy and paste the current contents of one and edit it. 0 Quote Link to comment Share on other sites More sharing options...
bhavicp Posted May 23, 2010 Share Posted May 23, 2010 So you have to get your own info from the database? No easier way? 0 Quote Link to comment Share on other sites More sharing options...
tomdchi Posted May 23, 2010 Share Posted May 23, 2010 If you are wanting to display information in a different template then yes. Its very easy. For example the php file below will output to the template file 3 values that were queried from the database. <?php define("CLIENTAREA",true); require("dbconnect.php"); require("includes/functions.php"); require("includes/clientareafunctions.php"); $pagetitle = $_LANG['clientareatitle']; $pageicon = "images/support/clientarea.gif"; $breadcrumbnav = '<a href="index.php">'.$_LANG['globalsystemname'].'</a>'; $breadcrumbnav .= ' > <a href="mypage.php">My Page</a>'; initialiseClientArea($pagetitle,$pageicon,$breadcrumbnav); if ($_SESSION['uid']) { # User is Logged In - put any code you like here $query="SELECT * FROM tblclients WHERE id='".$_SESSION['uid']."'"; $result = mysql_query($query) or die('Error, query failed'); while ($data = mysql_fetch_array($result)) { $firstname = $data['firstname']; $lastname = $data['lastname']; $email = $data['email']; } $smartyvalues['firstname'] = $firstname; $smartyvalues['lastname'] = $lastname; $smartyvalues['email'] = $email; } # To assign variables in Smarty use the following syntax. # This can then be used as {$variablename} in the template //$smartyvalues["variablename"] = $value; # Define the template filename to be used without the .tpl extension $templatefile = "mynewtemplate"; outputClientArea($templatefile); ?> For this example you would need a template file called mynewtemplate.tpl that would be located in the templates folder. You would use the tags {$firstname} {$lastname} {$email} in the html to display the values assigned to smarty. I try to name my template files the same as the php file so its easy to find which php file goes with what template. 0 Quote Link to comment Share on other sites More sharing options...
regrettably Posted May 24, 2010 Author Share Posted May 24, 2010 If you are wanting to display information in a different template then yes. Its very easy. For example the php file below will output to the template file 3 values that were queried from the database. <?php define("CLIENTAREA",true); require("dbconnect.php"); require("includes/functions.php"); require("includes/clientareafunctions.php"); $pagetitle = $_LANG['clientareatitle']; $pageicon = "images/support/clientarea.gif"; $breadcrumbnav = '<a href="index.php">'.$_LANG['globalsystemname'].'</a>'; $breadcrumbnav .= ' > <a href="mypage.php">My Page</a>'; initialiseClientArea($pagetitle,$pageicon,$breadcrumbnav); if ($_SESSION['uid']) { # User is Logged In - put any code you like here $query="SELECT * FROM tblclients WHERE id='".$_SESSION['uid']."'"; $result = mysql_query($query) or die('Error, query failed'); while ($data = mysql_fetch_array($result)) { $firstname = $data['firstname']; $lastname = $data['lastname']; $email = $data['email']; } $smartyvalues['firstname'] = $firstname; $smartyvalues['lastname'] = $lastname; $smartyvalues['email'] = $email; } # To assign variables in Smarty use the following syntax. # This can then be used as {$variablename} in the template //$smartyvalues["variablename"] = $value; # Define the template filename to be used without the .tpl extension $templatefile = "mynewtemplate"; outputClientArea($templatefile); ?> For this example you would need a template file called mynewtemplate.tpl that would be located in the templates folder. You would use the tags {$firstname} {$lastname} {$email} in the html to display the values assigned to smarty. I try to name my template files the same as the php file so its easy to find which php file goes with what template. Thanks for the assistance, but I'm still having trouble displaying assigned IPs as well as domains. Here's what I go: <?php define("CLIENTAREA",true); require("dbconnect.php"); require("includes/functions.php"); require("includes/clientareafunctions.php"); $pagetitle = $_LANG['clientareatitle']; $pageicon = "images/support/clientarea.gif"; $breadcrumbnav = '<a href="index.php">'.$_LANG['globalsystemname'].'</a>'; $breadcrumbnav .= ' > <a href="mypage.php">My Page</a>'; initialiseClientArea($pagetitle,$pageicon,$breadcrumbnav); if ($_SESSION['uid']) { # User is Logged In - put any code you like here $query="SELECT * FROM tblhosting WHERE id='".$_SESSION['uid']."'"; $result = mysql_query($query) or die('Error, query failed'); while ($data = mysql_fetch_array($result)) { $assignedips = $data['assignedips']; $domain = $data['domain']; } $smartyvalues['assignedips'] = $assignedips; $smartyvalues['domain'] = $domain; # To assign variables in Smarty use the following syntax. # This can then be used as {$variablename} in the template //$smartyvalues["variablename"] = $value; # Define the template filename to be used without the .tpl extension $templatefile = "mynewtemplate"; outputClientArea($templatefile); ?> {$assignedips} {domain} "{$assignedips}" is not showing up at all and "{domain}" is just showing a random domain in the database that is not related to an individual account. Any help on this matter is greatly appreciated! Thanks again! 0 Quote Link to comment Share on other sites More sharing options...
tomdchi Posted May 24, 2010 Share Posted May 24, 2010 thats because your query is calling id from tblhosting and not userid. As in $query="SELECT * FROM tblhosting WHERE userid='".$_SESSION['uid']."'"; 0 Quote Link to comment Share on other sites More sharing options...
regrettably Posted May 24, 2010 Author Share Posted May 24, 2010 thats because your query is calling id from tblhosting and not userid. As in $query="SELECT * FROM tblhosting WHERE userid='".$_SESSION['uid']."'"; It worked! Thank you very much! I'v spend weeks trying to figure this out! I'm also trying to setup a "foreach" for the domains displayed. Here is what I got: {foreach key=num item=service from=$services} {$domain} {foreachelse} {$LANG.norecordsfound} {/foreach} Do you know where I would find and get "$services" in the database? Where $services would equal the number of products and services a client has? Thanks again for all your help! 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.