Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Just wondered if anyone has a bit of code that will allow me to put the subcategories that are listed on a page within an infobox rather than the way they are now...

 

Ive tried to modify the code in default.php but i just cant seem to get it to work right...

 

Any help would be most appreciative.

 

I would assume this is the code:

 

<table border="0" width="100%" cellspacing="0" cellpadding="2">

             <tr>

<?php

   if ($cPath && ereg('_', $cPath)) {

// check to see if there are deeper categories within the current category

     $category_links = array_reverse($cPath_array);

     for($i=0; $i<sizeof($category_links); $i++) {

       $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 = '" . $category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by sort_order, cd.categories_name");

       if (tep_db_num_rows($categories_query) < 1) {

         // do nothing, go through the loop

       } else {

         break; // we've found the deepest category the customer is in

       }

     }

   } 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 = '" . $current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by sort_order, cd.categories_name");

   }



   $rows = 0;

   while ($categories = tep_db_fetch_array($categories_query)) {

     $rows++;

     $cPath_new = tep_get_path($categories['categories_id']);

     $width = (100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';

     echo '                <td align="center" class="smallText" style="width: ' . $width . '" valign="top"><a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . $categories['categories_image'], $categories['categories_name'], SUBCATEGORY_IMAGE_WIDTH, SUBCATEGORY_IMAGE_HEIGHT) . '<br>' . $categories['categories_name'] . '</a>' . "n";

     if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != tep_db_num_rows($categories_query))) {

       echo '              </tr>' . "n";

       echo '              <tr>' . "n";

     }

   }

?>

             </tr>

           </table>

 

What i want to do is create an infobox that displays the sub categories in a line by line fashion inside an infobox

 

so the categories would look like:

 

subcategory1, subcategory2, subcategory3 , subcategory4 ,subcategory5

subcategory6, subcategory7, subcategory8 , subcategory9, subcategory10

 

and so on....

 

If someone could knock up a bit of code id be most appreciative

  • 1 year later...
Posted

Hello,

 

Have you got the solution for this prob? if so pls guide me how did u achieve this?

 

thanks in advance,

 

Regards,

 

Prab

  • 1 year later...
Posted

First of all wat to thank you :) I use this code maybe can help you

But not include images :(

 

<?php

 

if ($cPath && ereg('_', $cPath)) {

 

// check to see if there are deeper categories within the current category

 

$category_links = array_reverse($cPath_array);

 

for($i=0; $i<sizeof($category_links); $i++) {

 

$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.parent_id = '" . $category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by sort_order, cd.categories_name");

 

if (tep_db_num_rows($categories_query) < 1) {

 

// do nothing, go through the loop

 

} else {

 

break; // we've found the deepest category the customer is in

 

}

 

}

 

} 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.parent_id = '" . $current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . $languages_id . "' order by sort_order, cd.categories_name");

 

}

 

 

 

$rows = 0;

 

while ($categories = tep_db_fetch_array($categories_query)) {

 

$rows++;

 

$cPath_new = tep_get_path($categories['categories_id']);

 

$width = (100 / MAX_DISPLAY_CATEGORIES_PER_ROW) . '%';

 

echo ' <a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_new, 'NONSSL') . '">' . $categories['categories_name'] . '</a><br>' . "";

 

if ((($rows / MAX_DISPLAY_CATEGORIES_PER_ROW) == floor($rows / MAX_DISPLAY_CATEGORIES_PER_ROW)) && ($rows != tep_db_num_rows($categories_query))) {

 

echo ' </tr>' . "";

 

echo ' <tr>' . "";

 

}

 

}

 

?>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...