Page tree
Skip to end of metadata
Go to start of metadata

 

Introduction

This tutorial uses PHP to create a new cPanel interface for the Paper Lantern theme. The examples below use the Paper Lantern theme's master template, which creates new interfaces that integrate seamlessly with the look and feel of the main cPanel interface.

Note:

For help to create a new cPanel interface in Template Toolkit, read our Create a New Paper Lantern Interface tutorial. 

Create a new Paper Lantern interface



Create a PHP file and connect to the LiveAPI system.

To begin, create a new PHP file. This file must use the .php file extension.

In the example below:

<?php
include("/usr/local/cpanel/php/cpanel.php");  // Instantiate the CPANEL object.
$cpanel = new CPANEL();                       // Connect to cPanel - only do this once.
?>

<?php
$cpanel->end();                               // Disconnect from cPanel - only do this once.
?>

 


 

Add Paper Lantern's header and footer.

Use the header() and footer() methods to add Paper Lantern's header and footer to the interface.

In the example below:

  • Line 4 uses the LiveAPI header() method to add Paper Lantern's header to the top of the interface, and set Page Heading as the page title.
  • Line 8 uses the LiveAPI footer() method to add Paper Lantern's footer to the bottom of the interface.
<?php
include("/usr/local/cpanel/php/cpanel.php");  // Instantiate the CPANEL object.
$cpanel = new CPANEL();                       // Connect to cPanel - only do this once.
print $cpanel->header( "Page Heading , app_key" );      // Add the header.
?>

<?php
print $cpanel->footer();                      // Add the footer.
$cpanel->end();                               // Disconnect from cPanel - only do this once.
?>

 


 

 

Add a UAPI function.

The LiveAPI uapi() method calls UAPI functions.

In the example below, lines 7 through 14 use LiveAPI's uapi() method to call UAPI's DomainInfo::domains_data function.

<?php
include("/usr/local/cpanel/php/cpanel.php");  // Instantiate the CPANEL object.
$cpanel = new CPANEL();                       // Connect to cPanel - only do this once.
print $cpanel->header( "Page Heading" );      // Add the header.
?>

<?php
$get_userdata = $cpanel->uapi(                // Get domain user data.
    'DomainInfo', 'domains_data',
    array(
        'format'    => 'hash',
    )
);
?>

 <?php
print $cpanel->footer();                      // Add the footer.
$cpanel->end();                               // Disconnect from cPanel - only do this once.
?>