Home | Store | osCommerce Tutorials

osCommerce Main Categories Content File Structure

Part 5 - How tep_show_category() function list out all items of Main Categories


In this osCommerce tutorial, we will study a bit deeper how the tep_show_category() function listing out all items of the osCommerce Main Categories in order.

Let's recall the main code structure of categories.php again:

function tep_show_category($counter) {
global $tree, $categories_string, $cPath_array;

// More codes here....
// More codes here...
// More codes here...

 

$categories_string .= '<br>';

if ($tree[$counter]['next_id'] != false) {
tep_show_category($tree[$counter]['next_id']);
}

}

The $counter is actually the $tree array that used to trace the Categories items one by one.

The $tree, $categories_string and $cPath_array are global variables so that they can also be retrieved in the function.

The codes are better explained in the following diagram:

Browsing osCommerce Homepage:

osCommerce tep_show_category function

Browsing osCommerce Hardware Parent Categories:

osCommerce tep_show_category function

Hm... Very interesting. We know how the osCommerce Main Categories is listing.