Child pages
  • UAPI Functions - SiteTemplates::list_site_templates

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

Excerpt
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
titleNote:

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

Multiexcerpt include
MultiExcerptNameTemplateDirectories
PageWithExcerptGuide to Site Publisher Templates - The Configuration File

Multiexcerpt include
SpaceWithExcerptcom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@12665
MultiExcerptNameAPIDisabledWebServerRole
PageWithExcerptLIB:_ServerRoleDisabledAPI

Panel
bgColor#F2F2F2
borderStylenone

Examples 


Panel
bgColor#FFFFFF
borderStylenone


Expand
titlecPanel or Webmail Session URL


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

Include Page
LIB:_CallUAPIFromBrowserLink
LIB:_CallUAPIFromBrowserLink


Expand
titleLiveAPI PHP Class


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

Include Page
LIB:_LiveAPIPHPLink
LIB:_LiveAPIPHPLink

 


Expand
titleLiveAPI Perl Module


Code Block
languageperl
linenumberstrue
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',
);

Include Page
LIB:_LiveAPIPerlLink
LIB:_LiveAPIPerlLink

 


Expand
titlecPanel Template Toolkit


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

Include Page
LIB:_TTLink
LIB:_TTLink

 


Expand
titleCommand Line


Code Block
uapi --user=username SiteTemplates list_site_templates

Include Page
LIB:_UAPICLINote
LIB:_UAPICLINote


Expand
titleOutput (JSON)


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


Include Page
LIB:_cPanelAPIShellNote
LIB:_cPanelAPIShellNote

   


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:

Multiexcerpt include
MultiExcerptNameTemplateDirectories
PageWithExcerptGuide to Site Publisher Templates - The Configuration File
Note
titleNote:

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
titleNote:

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



Expand
titleClick to view...

/var/cpanel/customizations/site_templates