UAPI Functions - SiteTemplates::publish



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

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

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

 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.'} ); %]

 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.

 Output (JSON)

   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{ 
      "transformed":1
   },
   "data":null,
}

 

Note:

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

 

Parameters

Parameter

Type

Description

Possible values

Example

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

source

string

The desired template's source directory.

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

Note:

You must include either the sourceparameter or thepath and templateparameters. 

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 

path

string

The directory that contains the template's source directory.

Note:

You must include either the sourceparameter or thepath and templateparameters. 

 

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

template

string

The template's directory's name.

Note:

You must include either the sourceparameter or thepath and templateparameters. 

 A valid string.

under_construction

parameter_name

 string 

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 third-party template, consult that template's documentation or itsmeta.jsonfile.

A valid string.

My Website

 

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