Using Files Containing Boilerplate Text in the osCommerce Product Description
Relevance: osCommerce 2.2rc2a and forward. The same approach can be used in prior versions.
Donate: This is free software. Show your appreciation by supporting my efforts.

Related: Using Boilerplate Text in the Product Description
Create the directory
catalog/includes/languages/<your-language>/boilerplateYou will populate this directory with files whose names are <some-keyword>.html. For instance, suppose you have some text you want to add to all your DVD products. Create a file called DVD.html in this directory, i.e.
catalog/includes/languages/<your-language>/boilerplate/DVD.htmlPut whatever HTML marked-up text you want in that file.
Now go to
catalog/product_info.phpReplace
<p><?php echo stripslashes($product_info['products_description']); ?></p>
with this code:
<?php function html_include_cb($match) { $prefix = "HTML_INCLUDE_"; $match_filename = str_replace($prefix, '', $match[0]); $filename = DIR_WS_LANGUAGES . $_SESSION['language'] . '/boilerplate/' . $match_filename . ".html"; $buffer = ""; if (file_exists($filename)) { $handle = @fopen($filename, "r"); while (!feof($handle)) { $buffer .= fgets($handle, 4096); } fclose($handle); } return $buffer; } $products_description = $product_info['products_description']; $pattern = "/HTML_INCLUDE_[a-zA-Z0-9]*/"; $products_description = preg_replace_callback($pattern, "html_include_cb", $products_description, -1); echo '<p>' . stripslashes($products_description) . '</p>'; ?>
Now to use this logic, all you need to do is enter HTML_INCLUDE_DVD in the product description (under Admin - Categories), and when you display the product info page, it will be changed. For any HTML_INCLUDE_SomeAlphanumericString you add to a product description, simply create a file called
includes/languages/<your-language>/boilerplate/SomeAlphanumericString.htmland it will automatically be displayed. Note that the string really does have to be alphanumeric; don't use dashes, underscores, spaces or special characters in the name.
Although this tip describes the additive use of HTML Boilerplate, it can also be used to completely replace the product description which is entered in the osCommerce Admin Panel.