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

 

Description

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:

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. 

Examples 


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/SiteTemplates/publish?target=%2Fhome%2Fexample%2Fpublic_html&source=%2Fusr%2Flocal%2Fcpanel%2Fetc%2Fsite_templates%2Funder_construction&sitename=My%20Website&description=I%20have%20a%20website%20now

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

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

Note:

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

 

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

Note:

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

 

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

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":null,
}

Note:

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

   

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:

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:

  • /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.

/usr/local/cpanel/etc/site_templates/under_construction
pathstring

The directory that contains the template's source directory.

Note:

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

  • /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.

/usr/local/cpanel/etc/site_templates
templatestring

The template's directory's name.

Note:

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.

Notes:

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