Personalizing osCommerce - InfoBoxes, step one (Page 5 of 6 )
The infoBoxes are a versatile and dynamic feature of the catalog. Different pages or actions will cause different boxes to be displayed, and one of the things you may want to do is create your own infoBox. This is a three-part process. It starts with the file that actually creates the infoBox. For this example, I’ll show you how to make a box called links.php, containing links taken from other areas of the site.
You may be used to using notepad to create HTML and script files. For working in PHP, you may find that one of the many specialist code editors that are available will help make your life easier. I like to use the excellent Xint text editor: it’s free, it has line numbers (useful for debugging) and it features color coding (which helps you sort your HTML from your PHP and your If statements from your XML). It has a whole bunch of other features too, but these are the main benefits.
Whichever text editor you use, open it now and add the PHP declaration and an ID and date comment:
<?php
/*
$Id: links.php,v 1.01 2004/06/28 01:13:58 hpdl Exp $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Released under the GNU General Public License
*/
?>
To keep with the consistency of the pre-defined boxes, the above statement should be kept intact, and comments used to mark the beginning and end of the box:
<!-- links //-->
In order to give the box an appropriately colored heading bar, you’ll need to embed your box in a table and include the following array:
<tr>
<td>
<?php
$link_box_contents = array();
$link_box_contents[ ] = array('text' => BOX_HEADING_LINKS);
The box heading is defined in another file, which is explained in full in step two. For the actual links, add the following code:
$link_box_contents = array();
$link_box_contents[ ]= array('text' =>
'<a href=" ' . tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL') . '">' .
BOX_LINKS_CREATE_ACCOUNT . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_LOGIN, '', 'SSL') . '">' .
BOX_LINKS_LOGIN . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_ACCOUNT, '', 'SSL') . '">'.
BOX_LINKS_MY_ACCOUNT . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' .
BOX_LINKS_CART_CONTENTS . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL') . '">' .
BOX_LINKS_CHECKOUT . '</a>');
new linkBox($link_box_contents);}
?>
The names of your links can be changed of course, but essentially, once you have finished the code:
</td>
</tr>
<!-- links_eof //-->
then saved the file as links.php, step one is pretty much complete. Upload the file in the normal way to the includes folder.
Next: InfoBoxes, steps two and three >>
More Web Authoring Articles
More By Dan Wellman