UAPI Functions - SiteTemplates::list_site_templates

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

 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'
);

 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',
);

 cPanel Template Toolkit

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

 Command Line

uapi --user=username SiteTemplates list_site_templates

 

Notes:

  • You must URI-encode values.
  • username represents your account-level username.

 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 (Home >> Advanced >> API Shell) to directly test cPanel API calls.

 

Parameters

This function does not accept parameters.

Returns

Return

Type

Description

Possible values

Example

 

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 ameta.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. 

 

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....