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.

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

Examples 




https://hostname.example.com:2083/cpsess##########/execute/SiteTemplates/list_site_templates



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

 



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

 



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

 



uapi --user=username SiteTemplates list_site_templates



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



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 contains a meta.json template information file and exists within one of the following directories:

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.

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



/var/cpanel/customizations/site_templates