WHMCS – How to create custom pages

In this tutorial I’m going to show you how to create custom pages in WHMCS. This guide will focus on our professional WHMCS themes but should work with any WHMCS installation/theme/template.

Creating your first WHMCS custom page

Let’s say for example that you would like to create a page called Windows Hosting.

1) Create the page title

The page title is taken from the WHMCS language files which are located at /whmcs/lang/ for example /whmcs/lang/English.php. You will need to add the following code to all of the language files you support (and translate if applicable):

$_LANG['windowshosting'] = "Windows Hosting";

The text highlighted in red is used to reference the page title in the .php file created below. This can be anything you like (no special characters/spaces). To the right of that inside the double quotes is the name of the page.

1) Create the .php page

This page will have all of the functionality required to load the page and assign it the above page title. Luckily this code is provided by WHMCS, however I have simplified their example as much as I could.

Create a new .php file in the root of WHMCS. I always recommend using the page title without spaces and capitations, in this case it will be windows-hosting.php. This file needs to contain the following code:


<?php

define("CLIENTAREA",true);
//define("FORCESSL",true);

require("dbconnect.php");
require("includes/functions.php");
require("includes/clientareafunctions.php");

$pagetitle = $_LANG['windowshosting'];
$breadcrumbnav = '<a href="index.php">'.$_LANG['globalsystemname'].'</a>';
$breadcrumbnav .= ' > <a href="windows-hosting.php">Windows Hosting</a>'; 

initialiseClientArea($pagetitle,'',$breadcrumbnav);

if ($_SESSION['uid']) {

$result = mysql_query("SELECT firstname FROM tblclients WHERE id=".(int)$_SESSION['uid']);
$data = mysql_fetch_array($result);
$clientname = $data[0];
$smartyvalues["clientname"] = $clientname;

} else {

# User is not logged in

}

$templatefile = "windows-hosting"; 

outputClientArea($templatefile);

?>

Focus only on the areas I’ve highlighted in red.

Line 4: If you’d like the page when loaded to use https:// (for a secure SSL connection) instead of http:// remove the 2 backslashes at the start of the line.

Line 10: This line references the page title we created in step 1. As you can see I’ve added windowshosting so it will load Windows Hosting from the language file that the visitor has selected.

Line 12: The first text needs to be the name of this .php file. In this example it is windows-hosting.php. The second is the page name.

Line 29: Lastly this is the name of the .tpl file we’ll be creating in the next step. I recommend using the same name as the .php file. So in this case without the extension it is windows-hosting

3) Create the .tpl file

This last file is where you’ll need to add your content for this particular custom page. It needs to be named exactly in line 35 of the above code but with the .tpl extension. So in this case it is windows-hosting.tpl. This file needs to be created in the following directory:

/public_html/templates/YOUR_TEMPLATE/

As a example add the following basic content to this file:

<h2>This is a page title</h2>

<p>This is a paragraph</p>

4) Viewing the new file

The new file will now be viewable at:

yourdomain.com/windows-hosting.php

You’ve now successfully created your very first custom page!

premium whmcs templates

If you have any questions/problems feel free to leave a comment below.

Popularity: 51%

About The Author

Hello, my name is . I run Zomex.com and have a great passion for the web in general but more specifically web design & web hosting. I also enjoy helping others and do everything I can to provide the best support to Zomex customers.

View more posts (153) by



3 Comments.

  1. chuck - December 29th, 2011 -

    this may answer some of my hack work !!! but how to add the above in a menu button, looks as though i could cut and paste a previous button code and change some to make it work ?????

    Reply

    • Jack Curtis - December 29th, 2011 -

      Hello Chuck,

      That’s correct, this guide will allow you to create pages that are the same as the others (already integrated).

      The HTML to add a link to the menu is:

      <li><a href="page.php" rel="nofollow">Link</a></li>

      ^ Note, remove the rel=”nofollow” bit. That’s automatically added by WordPress in this comment but you don’t want to add that in the template.

      Jack

      Reply

  2. feri - January 12th, 2012 -

    oh,, good!!

    Reply

Leave a Reply!