Sanitize the Best Sellers InfoBox

In this post, I’m going to show how to take out some of the usual osCommerce code and replace it with sanitised (clean), semantically correct code!

The fiel we are working on is /includes/boxes/best_sellers.php

Find this code:

$bestsellers_list = '<table border="0" width="100%" cellspacing="0" cellpadding="1">';
while ($best_sellers = tep_db_fetch_array($best_sellers_query)) {
$rows++;
$bestsellers_list .= '<tr><td class="infoBoxContents" valign="top">' . tep_row_number_format($rows) . '.</td><td class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers['products_id']) . '">' . $best_sellers['products_name'] . '</a></td></tr>';
}
$bestsellers_list .= '</table>';

And replace with

$bestsellers_list = '<ol>';
while ($best_sellers = tep_db_fetch_array($best_sellers_query)) {
$rows++;
$bestsellers_list .= '<li><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers['products_id']) . '">' . $best_sellers['products_name'] . '</li>';
}
$bestsellers_list .= '</ol>';

What we have done here is strip out a table (always a good thing!) and replace it with a numbered list (ol).  osCommerce makes far too much use of tables to simply position items – which should be done using sematically correct HTML and CSS.

This little change in the best sellers box is the first step towards making osCommerce semantically correct!

Leave a Reply

Your email address will not be published. Required fields are marked *