Difference between revisions of "Developers API Overrides"

From Zen Cart(tm) Wiki
Jump to: navigation, search
(Initial description of override system)
(Added more information)
Line 20: Line 20:
 
{{infoBox|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.}}
 
{{infoBox|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 language file <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/languages/english.php</em>. You first create an override directory for your template at the same level, that is, in <em style="font-family:Courier;font-style:normal;">includes/languages/</em>. Now you have a directory called <em style="font-family:Courier;font-style:normal;">includes/languages/your_custom_template/</em>. Copy the file <em style="font-family:Courier;font-style:normal;">includes/languages/english.php</em> to your override directory; now you have a file called <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/languages/your_custom_template/english.php</em>. Make your desired changes to this file, and they will be picked up and used by the override system.
+
For example, suppose you wish to make changes to the file <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/languages/english.php</em>. You first create an override directory for your template at the same level, that is, in <em style="font-family:Courier;font-style:normal;">includes/languages/</em>. Now you have a directory called <em style="font-family:Courier;font-style:normal;">includes/languages/your_custom_template/</em>. Copy the file <em style="font-family:Courier;font-style:normal;">includes/languages/english.php</em> to your override directory; now you have a file called <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/languages/your_custom_template/english.php</em>. Make your desired changes to this file, and they will be picked up and used by the override system.
  
 
=== Language overrides ===
 
=== Language overrides ===
Line 35: Line 35:
 
</em>
 
</em>
  
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 a file in the directory <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/languages/english/extra_definitions/</em>, you would place a copy in <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/languages/english/extra_definitions/your_custom_template/</em>.
+
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 <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/languages/english/extra_definitions/some_file.php</em>, you would copy it to <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/languages/english/extra_definitions/your_custom_template/some_file.php</em> and edit this file.
  
 
Repeat for every language your store uses.
 
Repeat for every language your store uses.
Line 47: Line 47:
 
First, create the folder <em style="font-family:Courier;font-style:normal;">includes/templates/your_custom_template</em>. As you customize your store, you will copy files from <em style="font-family:Courier;font-style:normal;">includes/templates/template_default/</em> over to <em style="font-family:Courier;font-style:normal;">includes/templates/your_custom_template/</em>, always preserving the directory structure.
 
First, create the folder <em style="font-family:Courier;font-style:normal;">includes/templates/your_custom_template</em>. As you customize your store, you will copy files from <em style="font-family:Courier;font-style:normal;">includes/templates/template_default/</em> over to <em style="font-family:Courier;font-style:normal;">includes/templates/your_custom_template/</em>, always preserving the directory structure.
  
For example, if you want to modify the CSS for your store, you will copy the file <em style="font-family:Courier;font-style:normal;">includes/templates/template_default/css/stylesheet.css</em> to <em style="font-family:Courier;font-style:normal;">includes/templates/your_custom_template/css/stylesheet.css</em>, and modify this copy.
+
For example, if you want to modify the CSS for your store, you will copy the file <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/templates/template_default/css/stylesheet.css</em> to <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/templates/your_custom_template/css/stylesheet.css</em>, and modify this copy.
  
 
=== Module overrides ===
 
=== Module overrides ===
 +
 +
You can override files in the folder <em style="font-family:Courier;font-style:normal;">includes/modules/</em>.
 +
 +
{{infoBox|Note:|The override system does not yet extend to files in the subfolders order_total, pages, payment, or shipping.}}
 +
 +
First, create the folder <em style="font-family:Courier;font-style:normal;">includes/templates/your_custom_template</em>. As you customize your store, you will copy files from <em style="font-family:Courier;font-style:normal;">includes/modules/</em> over to <em style="font-family:Courier;font-style:normal;">includes/modules/your_custom_template/</em>.
 +
 +
For example, if you want to modify the product listing for your store, you will copy the file <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/modules/product_listing.php</em> to <em style="font-family:Courier;color:teal;font-weight:600;font-style:normal;">includes/modules/your_custom_template/product_listing.php</em>, and modify this copy.
  
 
=== Sidebox overrides ===
 
=== Sidebox overrides ===
 +
 +
You can override files in the folder <em style="font-family:Courier;font-style:normal;">includes/modules/sideboxes/</em>. These are the boxes that appear in the left and right columns of your store.
 +
 +
First, create the folder <em style="font-family:Courier;font-style:normal;">includes/modules/sideboxes/your_custom_template</em>. As you customize your store, you will copy files from <em style="font-family:Courier;font-style:normal;">includes/modules/sideboxes/</em> over to <em style="font-family:Courier;font-style:normal;">includes/modules/sideboxes/your_custom_template/</em>.
 +
 +
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.

Revision as of 11:58, 28 February 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.