Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Horizontal Category Descriptions


mushindo

Recommended Posts

The default way to display categories which contain subcategories is to show the category image and name underneath it in columns, usually 3, then starting a new row.

 

We recently had a client who wanted to show more detailed information on the categories in separate rows like this:

 

CATEGORY NAME:
Category description is shown here.

CATEGORY NAME:
Category description is shown here.

 

A sample can be seen here:

http://www.tsunamihosting.com/viteyes/index.php/cPath/40

 

So as such I created this minor change.

 

NOTE: This requires you have the category descriptions contribution installed onto your oscommerce store.

 

---------

 

Open index.php and look for this:

 

} else {
     $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status = '1' and c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
   }

   $number_of_categories = tep_db_num_rows($categories_query);

   $rows = 0;
   while ($categories = tep_db_fetch_array($categories_query)) {
     $rows++;
     $cPath_new = tep_get_path($categories['categories_id']);
     $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
     echo '                <td align="center" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a></td>' . "\n";
     if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) {
       echo '              </tr>' . "\n";
       echo '              <tr>' . "\n";
     }
   }

 

And replace with this:

 

} else {
     $categories_query = tep_db_query("select c.categories_id, cd.categories_name, cd.categories_description, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status = '1' and c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
   }

   $number_of_categories = tep_db_num_rows($categories_query);

   $rows = 0;
   while ($categories = tep_db_fetch_array($categories_query)) {
     //$rows++;
     $cPath_new = tep_get_path($categories['categories_id']);
     $width = (int)(100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';
     echo '                <td align="left" class="smallText" width="' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br><b>' . $categories['categories_name'] . '</b></a><br>' . $categories['categories_description'] . '</td>' . "\n";
     if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != $number_of_categories)) {
       echo '              </tr>' . "\n";
       echo '              <tr>' . "\n";
     }
   }

 

You should now see it as shown in the example above, plus with the category names bolded out. This will better help search engine rankings if you use your category descriptions effectively.

Sincerely,

Bruce

 

19 contributions submitted

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...