Jump to content

Help! New pages with product details


Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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!

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