Difference between revisions of "Developers API Overrides"

From Zen Cart(tm) Wiki
Jump to: navigation, search
m (Selecting your template in the Admin)
Line 1: Line 1:
 
{{Template:menuBarDevelopers}}
 
{{Template:menuBarDevelopers}}
 
== Overrides ==
 
== 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.)
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.
 
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.
Line 15: Line 14:
  
 
== How the template override system works ==
 
== 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 <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">your_custom_template</em>. 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.  
 
To make use of the override system, first name your custom template. In the examples below, we will call this <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">your_custom_template</em>. 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.  
  
Line 41: Line 39:
 
=== Template overrides ===
 
=== Template overrides ===
  
You can override any file in the path <em style="font-family:Courier;font-style:normal;">includes/templates/template_default</em>. These are the files that determine the layout and HTML formatting of your web pages. Zen Cart has three standard templates: <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">template_default</em>, <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">blue_strip</em>, and <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">classic</em>. You can see these folders in the <em style="font-family:Courier;font-style:normal;">includes/templates/</em> folder.
+
You can override any file in the path <em style="font-family:Courier;font-style:normal;">includes/templates/template_default</em>. These are the files that determine the layout and HTML formatting of your web pages. Zen Cart&trade; has three standard templates: <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">template_default</em>, <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">blue_strip</em>, and <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">classic</em>. You can see these folders in the <em style="font-family:Courier;font-style:normal;">includes/templates/</em> folder.
  
 
Of these three standard templates, only <em style="font-family:Courier;font-style:normal;">template_default</em> contains a full set of files. Every other template contains only the files that differ from <em style="font-family:Courier;font-style:normal;">template_default</em>; 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 <em style="font-family:Courier;font-style:normal;">template_default</em>.
 
Of these three standard templates, only <em style="font-family:Courier;font-style:normal;">template_default</em> contains a full set of files. Every other template contains only the files that differ from <em style="font-family:Courier;font-style:normal;">template_default</em>; 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 <em style="font-family:Courier;font-style:normal;">template_default</em>.
Line 66: Line 64:
  
 
For example, if you want to modify the "More Information" sidebox, you will copy the file <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/modules/sideboxes/more_information.php</em> to <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/modules/sideboxes/your_custom_template/more_information.php</em>, and modify this copy.
 
For example, if you want to modify the "More Information" sidebox, you will copy the file <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/modules/sideboxes/more_information.php</em> to <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/modules/sideboxes/your_custom_template/more_information.php</em>, and modify this copy.
 +
  
 
== Selecting your template in the Admin ==
 
== 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.
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'.
 
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'.

Revision as of 18:34, 26 July 2006

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.

Info.png Note:
The override system does not extend to every file in your store. You can tell that a particular directory uses the override system by checking for the folder "classic" in that directory. Any directory that contains a classic subdirectory can be overridden.

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.

Language overrides

You can override any file in the path includes/languages/. Create a folder named your_custom_template in each of the following directories:

  • includes/languages
  • includes/languages/english
  • includes/languages/english/extra_definitions
  • includes/languages/english/html_includes
  • includes/languages/english/modules/order_total
  • includes/languages/english/modules/payment
  • includes/languages/english/modules/shipping

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.

Template overrides

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.

Module overrides

You can override files in the folder includes/modules/.

Info.png Note:
The override system does not yet extend to files in the subfolders order_total, pages, payment, or shipping.

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.

Sidebox overrides

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