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

 

Description

This function lists available templates for cPanel's Site Publisher feature.

  • If you call this function as the root or system user, the function lists the root user's templates.
  • If you call this function as a reseller, the function lists the root user's templates and the reseller's templates.
  • If you call this function as a cPanel user, the function's output depends on the account's owner:
    • If the root user owns the account, the function only lists the root user's templates.
    • If a reseller owns the account, the function lists the root user's templates and that reseller's templates.

Note:

The template directory's location depends on whether the root user or a reseller owns the template.

  • /var/cpanel/customizations/site_templates/ — Templates that the root user owns.
  • /home/username/var/cpanel/reseller/site_templates/ — Templates that a reseller owns, where username represents the reseller's username.
  • /usr/local/cpanel/etc/site_templates/ — cPanel-provided templates.

Examples 


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/SiteTemplates/list_site_templates

Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// List the available website templates.
$templates = $cpanel->uapi(
    'SiteTemplates', 'list_site_templates'
);

Note:

For more information, read our Guide to the LiveAPI System.

 

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# List the available website templates.
my $templates = $cpliveapi->uapi(
    'SiteTemplates', 'list_site_templates',
);

Note:

For more information, read our Guide to the LiveAPI System.

 

 cPanel Template Toolkit
<!-- List the account's backup files. -->
[% data = execute( 'SiteTemplates', 'list_site_templates' ); %]
[% FOREACH q = data %]
     <p>
         [% q %]
     </p>
[% END %]

Note:

For more information, read our Guide to Template Toolkit documentation. 

 

 Command Line
uapi --user=username SiteTemplates list_site_templates

Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • We introduced this functionality in cPanel & WHM version 56.

 Output (JSON)
{  
   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{  
      "transformed":1
   },
   "data":[  
      {  
         "preview":1,
         "name":"mytemplate",
         "path":"/var/cpanel/customizations/site_templates"
      }
   ]
}

Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

   

Parameters

This function does not accept parameters.

Returns

ReturnTypeDescriptionPossible valuesExample
 hash

An unnamed hash of the authenticated user's available templates.

This hash includes the name, preview, and path returns.

 

name

string

The template's name.

The function returns this value in the unnamed hash.

The name of a directory that exists within the /var/cpanel/customizations/site_templates/ directory, the /var/cpanel/reseller/site_templates/ directory, or the /usr/local/cpanel/etc/site_templates/ directory, and which contains a meta.json template information file.

Note:

The template directory's location depends on whether the root user or a reseller owns the template.

mytemplate

preview

Boolean

Whether the template includes a preview image.

The function returns this value in the unnamed hash.

  • 1 — The template directory contains a preview.png file.
  • 0 — The template directory does not contain a preview.png file. The cPanel interface will display a placeholder image for this template.

1

path

string

The template directory path.

The function returns this value in the unnamed hash.

A valid path.

Note:

The template directory's location depends on whether the root user or a reseller owns the template. 

 Click to view...

/var/cpanel/customizations/site_templates