Difference between revisions of "Creating Pages"

From WHMCS Documentation

Line 7: Line 7:
 
   
 
   
 
  define("CLIENTAREA",true);
 
  define("CLIENTAREA",true);
 +
 
  require("dbconnect.php");
 
  require("dbconnect.php");
  require("includes/functions.php");  
+
  require("includes/functions.php");
 +
require("includes/clientareafunctions.php");
 
   
 
   
 
  $pagetitle = $_LANG['clientareatitle'];
 
  $pagetitle = $_LANG['clientareatitle'];
 
  $pageicon = "images/support/clientarea.gif";
 
  $pageicon = "images/support/clientarea.gif";
  $breadcrumbnav = '<a href="index.php">'.$_LANG['globalsystemname'].'</a> > <a href="mypage.php">My Page</a>';  
+
  $breadcrumbnav = '<a href="index.php">'.$_LANG['globalsystemname'].'</a>';
  require("init.php");  
+
$breadcrumbnav .= ' > <a href="mypage.php">My Page</a>';  
 +
   
 +
initialiseClientArea($pagetitle,$pageicon,$breadcrumbnav);
 
   
 
   
 
  if ($_SESSION['uid']) {
 
  if ($_SESSION['uid']) {
 
   # User is Logged In - put any code you like here
 
   # User is Logged In - put any code you like here
 
  }  
 
  }  
 +
 +
# 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
 
  # Define the template filename to be used without the .tpl extension
 +
 
  $templatefile = "homepage";  
 
  $templatefile = "homepage";  
 
   
 
   
  # To assign variables in Smarty use the following syntax. This can then be used as {$variablename} in the template
+
  outputClientArea($templatefile);
$smartyvalues["variablename"] = $value;
 
 
require("display.php");  
 
 
   
 
   
 
  ?>
 
  ?>

Revision as of 13:10, 15 December 2008

To add your own pages to the WHMCS system which utilise the WHMCS templating system, you may use the following code. This code is designed to work with files placed in the root whmcs directory. This is ideal for adding custom pages to the client area or building an entire site around your WHMCS system.

Create a new file using your favourite text editor such as notepad, copy and paste the following code into it:


<?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
} 

# 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 = "homepage"; 

outputClientArea($templatefile);

?>


Edit $breadcrumbnav and $templatefile to match the filename of the page you want to create. Eg. If you were creating a page called aboutus, you would edit $templatefile = "homepage"; to $templatefile = "aboutus";. Save this as a php file and upload to your root WHMCS directory (eg. example.com/whmcs)


Now create another text file, this is your template file and will contain the actual content for your custom page. Save this as a tpl file and upload to your templates directory (eg. example.com/whmcs/templates/*TEMPLATE NAME*).



To access your newly created custom page just visit the php file.