X-Cart:Editing Skin Files

From X-Cart 4 Classic
Revision as of 17:52, 1 February 2010 by Admin (talk | contribs) (Managing Skin Files)
Jump to: navigation, search

Introduction

An X-Cart skin typically includes PHP Smarty templates, CSS files, JavaScript files and, in some cases, HTML files.

The PHP Smarty templates of your store's skin are files out of which your store's pages are built. Each template file defines how a specific element of the site appears. Template files are made up of HTML/CSS and Smarty; all of them have the .tpl file extension.

The screenshot of the customer area below provides an example of how a page is created using templates:

Manual scheme for 4 2.gif

The CSS files of your store's skin are style sheets that define the presentation of your store's pages. They use the extension .css.

The JavaScript files of your store's skin are files that contain JavaScript code which can be called on your store's pages. They use the extension .js.

If you wish to change the look of a specific element of your store site, you need to edit the skin files that control this element. Most typically, you will need to edit X-Cart's template and CSS files. To be able to edit X-Cart's template and CSS files, you must possess substantial knowledge of HTML, CSS and Smarty. Here is a list of online resources that might be helpful:

HTML:

CSS:

Smarty:

All the files of your X-Cart skin are stored in the directory /xcart/skin1, where /xcart stands for the X-Cart installation directory. Your store's Admin area provides a section that allows you to view and manage the contents of this directory (see the section #Managing Skin Files).

The number of skin files in X-Cart is really large, so finding out which file controls what elements may require a great deal of effort. We recommend you begin by studying the chapters #Overview of Templates and #Overview of CSS Files. When you begin working on the skin files more closely, we also recommend you use the Debugging Console, a tool that will help you to find out the skin files for each page of the your X-Cart based store (See the section #Using X-Cart's Debugging Console).

X-Cart's skin files can be edited in X-Cart's built-in template editor (see the section #Using Template Editor), or in any decent external text editor.

Managing Skin Files

You can manage the contents of X-Cart's /xcart/skin1 directory using the 'Browse templates' section of your store's Admin area (Administration menu->Edit templates). The functionality of this section is similar to that of the 'Browse files' section (Management menu->Files): it provides a file browser that you can use to view the contents of the directory /xcart/skin1, to upload your own files, to copy and delete existing files, to create and delete sub-directories. In addition to the said operations, the file browser in this section allows you to compile templates (See the section [[#Compiling templates])] and to restore any skin files that have been edited to their original state (See #Restoring all files).

Templates.gif

The Quick access menu above the 'Browse templates' dialog box allows you to quickly access specific files/groups of files in /xcart/skin1:

Quick access menu.gif

Compiling templates

X-Cart allows you to "compile" templates, i.e. to replace the language variables used in your store's templates with the values of these variables. When your store's templates are compiled, the text stored in the language variables used in this template is inserted directly into the template code. This feature is useful for stores using only one language: compiling templates significantly reduces the time needed for template processing, because X-Cart does not need to use language variables.

If you choose to compile your store's templates, you will be able to edit any textual elements of your store's user interface in X-Cart's built-in template editor, but you will not be able to edit them using the 'Edit languages' section (Administration menu->Languages) or Webmaster mode.

To compile your store's templates, do the following:

  1. Go to the 'Browse templates' section of your store's Admin area (Administration menu->Edit templates). You should see a dialog box titled 'Browse templates'. At the bottom of the 'Browse templates' dialog box, you should see a button labeled Compile templates and a drop-down box labeled 'Language'. The 'Language' drop-down box contains a list of languages enabled at your store.
  2. From the 'Language' drop-down box, select the language you wish to use in the compiled templates.
  3. Click the Compile templates button. When prompted, confirm the deletion.

When you do that, X-Cart begins the compiling process. While X-Cart is compiling, you will be able to see the progress on the screen. Please be patient and allow sufficient time for the procedure to be completed.

At the end, a message should appear indicating the successful completion of the process: 'All templates are successfully compiled'. Shortly after the success message is displayed, you should be redirected back to the 'Browse templates' page.

Restoring all files

At any time you can restore your store's skin files to their original state (as in a fresh X-Cart installation). This is possible because X-Cart's directory /xcart/skin1_original stores a backup of the original skin files. When you perform the restoration procedure, any modified files of your store's skin are overwritten by the original files from this directory.

To enable X-Cart to restore the files of your store's skin from /xcart/skin1_original, you must ensure that the user under which PHP runs on your server has read and write permissions for the directory /xcart/skin1, as well as read and write permissions for all the files of the current skin stored in this directory.

To restore all the files of your X-Cart store, do the following:

  1. Go to the 'Browse templates' section of your store's back end (Administration menu->Edit templates). You should see a dialog box titled 'Browse templates'.
  2. In the 'Browse templates' dialog box, click the Restore All button.

When you click on Restore All, the skin files of your X-Cart stored in /xcart/skin1 are replaced by the original files from the directory /xcart/skin1_original.

Overview of Templates

Overview of CSS Files

Using Debugging Console

Using Template Editor

See also