Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Table of Contents
maxLevel2
styledisc
printablefalse

Designer Guide

The default PrestaShop install offers a neutral theme in shades of gray, enabling sellers to quickly and freely start their activity, whatever their business line.

...

Anyone with some knowledge of CSS and image manipulation can create a custom theme for PrestaShop. Provided you know PHP as well, you can build a whole new theme for your shop. Thanks to a tried and tested theme system, any shop can quickly sport a theme tailored to its needs.

That theme system is based on a template engine, called Smarty, which allows web-designers and developers to easily build their own theme, with little technical knowledge.

Tip

All web-designers and developers should use the following tools:

  • Firefox: Firebug is a free extension for easy comparison and debugging between your CSS and the output.
  • Firefox/Chrome: Web Developer adds many handy web developer tools to your browser.
  • Safari/Chrome: enable the Web Inspector.
  • Opera: Dragonfly, a fully-featured debugging environment.
  • Internet Explorer 8+: Developer Tools are available through the Tools menu.

Internet Explorer users can also make use of Firebug lite.

Concepts and technical information

How a theme works

A PrestaShop theme is a set of files which you can edit in order to change the look of your online shop.

Here are a few important tidbits:

  • All themes have their files located in the /themes root folder.
  • Each theme has its own sub-folder, in the main themes folder.
  • Each theme is made of template files (/tpl), image files (.gif, .jpg, .png), one or more CSS files (/css), and sometimes even JavaScript files (.js).
  • Each theme has a preview.jpg image file in its folder, enabling the shop-owner to see what the theme looks like directly from the back-office, and select the theme appropriately.

Here is an overview of the file structure of a PrestaShop theme (here, the default one):

Image Removed

  • The /css folder contains all CSS files.
  • The /img folder contains all images.
  • The /js folder contains all the JavaScript files.
  • The /lang folder contains the theme's translations. Its access rights should be set at CHMOD 666 (for instance), so that the back-office translation tool can read and write into it.
  • The root of the folder contains TPL files only (Smarty files), as well as the preview.jpg file.
Info

The /css, /img and /js folder are optional, the module can perfectly work without them, it's up to you to create them.

Handling translations

All of your theme's text string should be enclosed in a Smarty function, like so:

Code Block

{l s='My Text'}

This will enable anyone to translate the theme into his own language, using the internal translation tool, which you can find in the PrestaShop back-office, under the "Tools" tab and its "Translation" sub-tab. In the "Modify translations" section, use the drop-down menu, choose "Back Office translation", then click on the flag of the language you wish to translate strings into. All the back-office strings will then be displayed, and the strings for your theme are those whose sections are not prefixed with "Admin*".

Having data sent to a theme

PrestaShop uses a 3-tier architecture, in order to clearly separate concerns: it uses...

  • a presentation tier: the user interface.
  • an application tier: controls the data flow from and to the other two tiers. Also called "business tier".
  • a data tier: the databases themselves.

(schema)

Thanks to the l() function, the hello.tpl file can display text in the user's language of choice.

Best practices

Here is a non-exhaustive list of best practices that you should follow when creating a theme:

  1. Do not mix XHTML and PHP code.
  2. Do not mix XHTML and CSS code, put the CSS code in a separate .css file.
  3. Always validate your XHTML and CSS code using the W3C validators: XHTML validator, CSS validator.
  4. Do not make SQL queries from a PHP controller ({{.php file at the root of PrestaShop); prefer the use of existing methods from the PrestaShop classes, or create new methods for these classes.
  5. Always check if a method you need does not already exist in the available classes.
  6. Always make sure to produce a clear and readable code, making it easy to maintain for anyone.
  7. Do comment your code, in English.
  8. When editing the theme on a production site, always first put the shop in maintenance mode via the back-office.
  9. Use modern browsers, such as Firefox, Google Chrome or Opera, and make sure your friends do too.
  10. Whenever possible, use CSS sprites (follow-up article.
  11. If you wish to thank PrestaShop team for its hard work, please consider donating, or spread the good word!

Customizing the default theme

Follow the following steps below to create your own theme out of the PrestaShop default theme.

1. Copy the default theme

  1. Locate the ../themes directory in your PrestaShop install, and create a copy of the default ../themes/prestashop/ directory.
  2. Rename the duplicate.

Image Removed

2. Modify the CSS sheet

  • In the customized theme folder (e.g., ../themes/MyStoreTheme/), locate the /css folder.
  • Open the global.css file and change it according to your needs. This is where you are only limited by your creativity – and your knowledge of CSS.
    Note: the maintenance.css file, located in the same folder, controls the layout of the Maintenance Mode page.
  • New or modified images must be placed in the new theme's /img folder (e.g., ../themes/MyStoreTheme/img).
Tip
titleTips from the PrestaShop development team

3. Create a preview screen shot

Once your customized theme is ready, you must place a file representing the theme, called preview.jpg, in the theme's root folder (e.g., ../themes/MyStoreTheme). This file must be a 100 × 100 pixels .jpg file.

4. Test your theme

  1. Go to back-office's "Preferences" tab, then its "Appearance" and its "Themes" section.
  2. Select the new theme and click Save..

Image Removed

Share your themes!

Show off your hard work, get feedback, and build your reputation by sharing your theme in the Themes section of our Forum!

You can also sell your theme to PrestaShop users through our Addons website!

Integration: where the hooks and modules are

One of the key point of integrating content within a PrestaShop theme is to know where said content is displayed, and therefore where the various hooks and modules are located.

Here is a graphical representation of where they are, for each page. You will find:

  • The name of the block.
  • The block's id, in order to target it with CSS.
  • The block's folder or template file, if you need to make changes to it.

Hooks

Main content areas

Image Removed

Header section

Image Removed

Homepage blocks

Image Removed

Category central column

Image Removed

Modules

Product page

Image Removed

Account forms & order steps

Image Removed

Account creation form

Image Removed

Order blocks

Image Removed

Addresses

Image Removed

Terms & Conditions and carrier choice

Image Removed

Payment module choice

Image Removed

Site map

Image Removed

Contact form

Image Removed

Stores page

Image Removed

Children Display

Training

PrestaShop also offers a complete training program tailored for designers. Contact us through this page: http://www.prestashop.com/en/training