How to create a new template

There are two ways to create a new template:
1. Automated generation by command line
2. Manual creation

1.  Automatic 
Use S-Cart's built-in command line to create new templates

php artisan sc:make template --name=your-new-template

After successful creation, you will get 2 new folders containing template files:

app/public/templates/your-new-template

and

resources/views/templates/your-new-template

Access to Admin/Extensions/Template,you will see this template in the "Saved local" Tab

2. Manual


Step 1: Create a new template folder
Copy and rename the folders public/templates/s-cart-light and resources/templates/s-cart-light to the name of the new template.
Note:

These 2 folder names must be the same

Create new template

Step 2: Configure the new template information
- Change the file content resources/templates/new-template/config.json 
Note:

Value of  configKey must match the folder name of the new template


Create new template

Step 3: Set up installation information

Since S-Cart 6.6, we support setting the information when entering the system when the template is installed or removed.
The functions are defined in the file "Provider.php"


This function installs information for the whole system. This function is only called the first time the template is installed.

function sc_template_install_default() {}


This function contains the settings information for each store using the template. It is called when:
+ The main store installs the template for the first time in the system. The parameters are set for the main store.
+ When a new store is created, the parameters of the selected template will be set for this store.
+ When the store changes the new template, the parameters of this template will be set for the store
-> Therefore, the default data for the whole system, only setting 1 should not be placed here. Let's put them in sc_template_install_default()

function sc_template_install_store($storeId = null) {}

This function removes the default information

function sc_template_uninstall_default() {}

This function removes the installation information for the store

function sc_template_uninstall_store($storeId = null) {}

This function is called when the template is installed

function sc_template_install($data = []) {
    $storeId = $data['store_id'] ?? null;
    sc_template_install_default();
    sc_template_install_store($storeId);
}

This function is called when the template is removed from the system

function sc_template_uninstall($data = []) {
    $storeId = $data['store_id'] ?? null;
    sc_template_uninstall_default();
    sc_template_uninstall_store($storeId);
}



Step 4: Check the information

Access to admin/Extension/Template/Template manager to check new template information


Create new template

Step 5: Activate the new template

Access to admin/Shop setting/Store infomation ->Template, choose the template you want to use

Create new template
 

Related topics

Latest Document