Please note: This is old content; I have not worked on Prestashop since 2009.
Boilerplate in Product Description for PrestaShopA PrestaShop mod which allows you to save time and have more control over repeated text in your product descriptions.
Are you repeating text over and over again in your product descriptions? Tedious, isn't it. And what if you want to change it? This means you'll have to revisit every product description in every language and make the change. The boilerplate mod deals with these situations by allowing you to define the boilerplate text one time in one place, and then automatically insert it where appropriate.
Donate: This is free software. Show your appreciation by supporting my efforts.
Relevance: PrestaShop 1.2.4 and forward
Download: download link
Installation Instructions: click here
FAQ: click here
Current Version: 0.1
Support Thread: PrestaShop Boilerplate Support Thread
Overview:To save typing repetitive text in the product description field, and to facilitate easier mass changes of boilerplate text, it is advantageous to use strings which are defined in a single place. This mod allows you to do that.
Here's how it works:
- You create strings in a file as key-value pairs. The key
is the short form for the boilerplate, and the value is the boilerplate
itself. For example:
<?php $stringArray = array ( '%%SHIPPING_USA_ONLY%%' => "Shipping to USA only.", '%%SATISFACTION_GUARANTEED%%' => "Your satisfaction is guaranteed!" ); ?>
Select the desired product using the
Admin > Catalog > and modify the Description field.
Add the keys to product descriptions in each language.
Note at the bottom the addition of %%SHIPPING_USA_ONLY%%.
Do this for all languages. In French, we have defined another string,
'%%USA_SEULEMENT%%' => "Expédition aux Etats-Unis seulement.",It is added to the bottom of the description in French:
- When the key is encountered in a description when viewing
the catalog, it is automatically changed. Here it is in English:
... and in French:
- Back up everything! Try this in a test environment prior to installing it on a live shop.
- Unzip the mod and copy all files to the root folder of your shop.
- In the directory "modules/productboilerplate/strings/" there are files for English and French. Copying en.php (or fr.php if that is preferred), create additional files for every language you support, using the same filename conventions. The ISO strings for language, which are used as the filename, are also shown on the Prestashop downloads page.
- For each language you support, create strings in the languages files. All strings are stored in a PHP array called $stringArray. Simply follow the example in en.php, and add your strings to this array.
- Go to Admin > Modules and scroll down to the Products block. You will see Product Boilerplate there. Press the "Install" button.
- For each product you want to add boilerplate to, select the product from the page Admin > Catalog and modify the Description field. Click on the flag under Description to add it to each language.
You must now make a one line change to a core file. In the file
classes/Product.php, at the end of the function __construct(), add
this one line:
- Donate! Show your appreciation by supporting my efforts.
- You're done! Browse the products you have changed in each language you support to be sure it's all set.
Installation Issues:If it isn't working, please check two things:
- Have you made the change to classes/Product.php from step 7?
- Have you installed the module by pressing the "Install" button in Admin > Modules?
FAQQ: Why does this utility not use the PrestaShop translation tool?
A: Because the way strings are stored and used is different, and it would have been more confusing to do it the standard PrestaShop way.
Q: Why do I have to modify a core file?
A: Because there was no hook available that worked the way I wanted it to. I minimized the change by organizing the code in such a way that only one file had to be modified.
Q: Can I use the boilerplate mod to add images or more sophisticated content?
A: Sure! Suppose you have an image called img/made_in_canada.gif. Add to your modules/productboilerplate/strings/en.php the line
'%%MADE_IN_CANADA%%' => "<img src='img/made_in_canada.gif' />This product is proudly made in Canada.",Then add %%MADE_IN_CANADA%% to any product you wish, and the image and text will display as shown below.