About Club osCommerce

Showcasing osCommerce…the good, the bad and the ugly!

Follow osc_pro on Twitter

Sanitize the Best Sellers InfoBox

Written By Gary on Feb 03 2008 · Comments (0) Follow osc_pro on Twitter

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!


Buy Gary A Beer?
Buying me a "beer" helps me to keep my contributions updated and keep this blog alive - and you get a link from my homepage to your site. Cheers!


No Comments

No comments yet.

Leave a comment

RSS feed for comments on this post

Hot 100 osCommerce Shops

View the osCommerce HOT 100These are the best looking, most exceptional osCommerce Stores as voted for by you.

New to osCommerce - get inspiration from these beautiful shops. Reckon your site has what it takes to become a member of the HOT 100? Submit it!