Child pages
  • UAPI Functions - SiteTemplates::publish

Versions Compared

Key

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

Description

Excerpt
This function publishes a Site Publisher website.
  • This function uses the /scripts/process_site_template script to publish the Site Publisher website.
  • This function creates the configurations.json file in the specified directory.
    • This file contains the user-entered data for the Site Publisher website and uses 0700 permissions.
    • For more information, read our Guide to Site Publisher Templates documentation.
  • In cPanel & WHM version 58 and later, when users publish a Site Publisher website, the system first creates a backup tarball of the target directory's contents in the /site_publisher/backups/ directory within the user's home directory.
Note
titleNotes:
  • When users publish a Site Publisher website, the system logs template information and the target directory to the /usr/local/cpanel/logs/error_log file. 
  • The template directory's location depends on whether the root user or a reseller owns the template:
    Multiexcerpt include
    SpaceWithExcerptcom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@880
    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/publish?target=%2Fhome%2Fexample%2Fpublic_html&source=%2Fusr%2Flocal%2Fcpanel%2F3rdparty%2Fshare%2Fsite_templates%2Funder_construction&sitename=My%20Website&description=I%20have%20a%20website%20now

Include Page
LIB:_CallUAPIFromBrowserLink
LIB:_CallUAPIFromBrowserLink


Expand
titleLiveAPI PHP Class


Code Block
languagephp
linenumberstrue
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Publish a Site Publisher website.
$templates = $cpanel->uapi(
    'SiteTemplates', 'publish',
        array(
        'target'        => '/home/example/public_html',
        'source'        => '/usr/local/cpanel/3rdparty/share/site_templates/under_construction',
        'sitename'      => 'My Website',
        'description'   => 'I have a website now',
        )
);

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.
 
# Publish a Site Publisher website.
my $templates = $cpliveapi->uapi(
    'SiteTemplates', 'publish',
    {
        'target'        => '/home/example/public_html',
        'source'        => '/usr/local/cpanel/3rdparty/share/site_templates/under_construction',
        'sitename'      => 'My Website',
        'description'   => 'I have a website now',
    }
);

Include Page
LIB:_LiveAPIPerlLink
LIB:_LiveAPIPerlLink

 


Expand
titlecPanel Template Toolkit


Code Block
languagexml
<!-- Publish a Site Publisher website. -->
[% data = execute( 'SiteTemplates', 'publish', {'target' => '/home/example/public_html', 'source' => '/usr/local/cpanel/3rdparty/share/site_templates/under_construction', 'sitename' => 'My Website', 'description' => 'I have a website now.'} ); %]

Include Page
LIB:_TTLink
LIB:_TTLink

 


Expand
titleCommand Line


Code Block
uapi --user=username SiteTemplates publish target=%2Fhome%2Fexample%2Fpublic_html source=%2Fusr%2Flocal%2Fcpanel%2F3rdparty%2Fshare%2Fsite_templates%2Funder_construction sitename='My Website' description='I have a website now.'

Include Page
LIB:_UAPICLINote
LIB:_UAPICLINote


Expand
titleOutput (JSON)


Code Block
languagetext
linenumberstrue
{  
   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{  
      "transformed":1
   },
   "data":null,
}


Include Page
LIB:_cPanelAPIShellNote
LIB:_cPanelAPIShellNote


Parameters

ParameterTypeDescriptionPossible valuesExample

target

or

docroot

string

Required

The directory that will contain the Site Publisher website.

The absolute path to the desired domain's document root./home/example/public_html
sourcestring

The desired template's source directory.

If you do not specify a value, the system uses the path and template values to determine the template's source directory.

Note
titleNote:

You must include either the source parameter or the path and template parameters. 


The absolute path to a template directory that exists in one of the following directories:

Multiexcerpt include
SpaceWithExcerptcom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@880
MultiExcerptNameTemplateDirectories
PageWithExcerptGuide to Site Publisher Templates - The Configuration File

/usr/local/cpanel/3rdparty/share/site_templates/under_construction
pathstring

The directory that contains the template's source directory.

Note
titleNote:

You must include either the source parameter or the path and template parameters. 


Multiexcerpt include
SpaceWithExcerptcom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@880
MultiExcerptNameTemplateDirectories
PageWithExcerptGuide to Site Publisher Templates - The Configuration File

/usr/local/cpanel/3rdparty/share/site_templates/
templatestring

The template's directory's name.

Note
titleNote:

You must include either the source parameter or the path and template parameters. 


 A valid string.under_construction
parameter_namestring

The template's variables and values.

Note
titleNotes:
  • Use each variable's name as a parameter name for a parameter and value pair.
  • The template that you specify determines the values to define. You must include the appropriate data for the selected template.
    • If you use a cPanel-provided template, read our Guide to Site Publisher Templates documentation for more information.
    • If you use a third-party template, consult that template's documentation or its meta.json file.


A valid string.

My Website

Returns

This function only returns metadata.