Developers API Overrides
Zen Cart features a template override system that allows you to customize the look and functionality of your store without having to modify core files. (Note: the override system is not yet available for Admin files, and is not yet available for some Catalog files.)
The template override system also allows you to change your store's look and functionality on a seasonal basis, for example, by creating multiple templates.
There are currently 4 components of the override system:
- Language overrides
- Template overrides
- Module overrides
- Sidebox overrides
How the template override system works
To make use of the override system, first name your custom template. In the examples below, we will call this your_custom_template. You create a folder with this name in every directory that contains files you wish to modify. Place a copy of each file you wish to modify in the custom template directory at the same level; then modify this custom template copy, leaving the original file untouched.
For example, suppose you wish to make changes to the file includes/languages/english.php. You first create an override directory for your template at the same level, that is, in includes/languages/. Now you have a directory called includes/languages/your_custom_template/. Copy the file includes/languages/english.php to your override directory; now you have a file called includes/languages/your_custom_template/english.php. Make your desired changes to this file, and they will be picked up and used by the override system.
You can override any file in the path includes/languages/. Create a folder named your_custom_template in each of the following directories:
Create a copy of any file you wish to modify, and place it in the appropriate custom template directory. For example, if you wish to modify the file includes/languages/english/extra_definitions/some_file.php, you would copy it to includes/languages/english/extra_definitions/your_custom_template/some_file.php and edit this file.
Repeat for every language your store uses.
You can override any file in the path includes/templates/template_default. These are the files that determine the layout and HTML formatting of your web pages. Zen Cart has three standard templates: template_default, blue_strip, and classic. You can see these folders in the includes/templates/ folder.
Of these three standard templates, only template_default contains a full set of files. Every other template contains only the files that differ from template_default; that is, only the files that have been modified. If your template does not contain a particular file, Zen Cart will pull that file from template_default.
First, create the folder includes/templates/your_custom_template. As you customize your store, you will copy files from includes/templates/template_default/ over to includes/templates/your_custom_template/, always preserving the directory structure.
For example, if you want to modify the CSS for your store, you will copy the file includes/templates/template_default/css/stylesheet.css to includes/templates/your_custom_template/css/stylesheet.css, and modify this copy.
You can override files in the folder includes/modules/.
First, create the folder includes/templates/your_custom_template. As you customize your store, you will copy files from includes/modules/ over to includes/modules/your_custom_template/.
For example, if you want to modify the product listing for your store, you will copy the file includes/modules/product_listing.php to includes/modules/your_custom_template/product_listing.php, and modify this copy.
You can override files in the folder includes/modules/sideboxes/. These are the boxes that appear in the left and right columns of your store.
First, create the folder includes/modules/sideboxes/your_custom_template. As you customize your store, you will copy files from includes/modules/sideboxes/ over to includes/modules/sideboxes/your_custom_template/.
For example, if you want to modify the "More Information" sidebox, you will copy the file includes/modules/sideboxes/more_information.php to includes/modules/sideboxes/your_custom_template/more_information.php, and modify this copy.
Selecting your template in the Admin
Log in to your Admin panel and go to Tools::Template Selection. You should see your new custom template(s) in the list. Select the template you wish to use.
Note: In order for the Template to be on the list, the custom directory must be created in /includes/templates/ and the template_info.php sets the $template_name = 'Template Name'.