Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Browse by Categories


Guest

Recommended Posts

Download contribution: Browse by Categories

Version: 1.0

osCommerce: 2.2-MS1

Kudos: Gustavo Barreto - Main Categories v1.0b.

 

Displays a content box in the main page (default.php) with top and sub-level categories of current category level. Administrators can select to disable this content box from displaying or enabling it as a text link type or an image link type. Administrators can also select number of links to display per row and if sub-categories are to be displayed on the right side of each category.

 

This contribution adds a new configuration group, with ID 101, to the database. This new group is associated with 4 new configuration entries: DISPLAY_BROWSE_CATEGORIES to enable/disable displaying the content box, BROWSE_CATEGORIES_TYPE to set link type, DISPLAY_BROWSE_SUB_CATEGORIES to enable/disable displaying the sub-categories of a category and MAX_BROWSE_CATEGORIES_PER_ROW that must be set to the number of maximum categories to display in a row. Check the sql file for the default configuration values of each entry. If you want to see a demonstration, check this demo online shop, running at doCommerce. Bare in mind that the text is in Portuguese.

Link to comment
Share on other sites

  • 2 months later...
  • Replies 190
  • Created
  • Last Reply

Top Posters In This Topic

Download contribution: Browse by Categories

Version: 2.0

osCommerce: 2.2-MS2

Kudos: Gustavo Barreto - Main Categories v1.0b.

 

This new release is for osCommerce 2.2 MileStone 2. The changes are:

1. replace default.php with index.php.

2. replace application_top.php with filenames.php.

Edited by straider
Link to comment
Share on other sites

The best way to show demos of how this contribution works is to actually provide some screenshots. These screenshots have been added as a ZIP file to the community contributions storage place, at Browse by Categories - Screenshots. After downloading the ZIP file, open the JPG images on an image viewer. The images with filename starting with admin show how the administration presents the options to control the content of Browse by Categories. The content, depending on the options selected, can be viewed on the images with filenames starting with catalog:

 

catalog-option-image-sub-2 - content box with 2 images per row for main categories, along with their sub-categories as text.

catalog-option-image-sub-3 - content box with 3 images per row for main categories, along with their sub-categories as text.

catalog-option-text-no-sub-3 - content box with 3 main categories per row, without their sub-categories.

catalog-option-text-sub-2 - content box with 2 main categories per row, along with their sub-categories as text.

 

Thanks.

Link to comment
Share on other sites

azer,

 

I originally used Main Categories, from Gustavo A. Barreto A., but I then had to add some more features. I've added configuration settings to the database, that can be controlled by the administration part of osCommerce. This was done for the purpose of allowing more control in how the categories are displayed in the content box.

 

The Main Categories displays the sub-categories of each category below the category image, separated by bullets. I prefer to display the sub-categories on the right side of the category's image, each one on a new line. It also displays the same content, even if you go one level deeper in the categories hierarchy, while I prefer to display just the categories of that level and their sub-categories.

 

But in essence, is an Enhanced Main Categories. The code now has almost no resemblance with the original source from Gustavo, but the idea/concept behind it is the same.

 

Best regards,

Link to comment
Share on other sites

I like this contribution but i have just one problem:

 

when i click on a category in the index page in the next screen i have all subcategories repeat twice. What can i do to have subcategories just one time?What can i do to resolve this problem?

 

Thanks for your help Straider, yours is a very good contribution!

Link to comment
Share on other sites

azer,

 

If you use osCommerce 2.2 Milestone 1 than apply Browse by Categories v1.0.

 

The newest release, Browse by Categories v2.0, is for osCommerce 2.2 MileStone 2. I've packaged it as v2.0 because an user was having some difficulties (which were solved before I finished) installing the contribution under MS2. It's actually the same code, just with different install instructions to reflect the changes in osCommerce from application_top.php to filenames.php and from default.php to index.php.

Link to comment
Share on other sites

Hi Straider,

i still have the same problem with the double subcategories... i'm looking for a way to erase one of the subcategories module in the index.php or in the Browse by Categories module. Any ideas? Can you help me?

 

 

 

Thank You.

Link to comment
Share on other sites

tuca,

 

Can you please post the code of index.php where you have made any changes while adding Browse by Categories, please?

 

You should have these changes executed on the index.php (you're using 2.2-MS2):

 

Before changes (lines 114..125):

              </tr>
           </table></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
         <tr>
           <td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>
         </tr>
       </table></td>
     </tr>
   </table></td>

 

After changes (lines 114..132):

              </tr>
           </table></td>
         </tr>

         <!-- DWD Contribution -> Add: Browse by Categories v2.0. !-->
         <tr>
           <td><?php $browse_category_id = $current_category_id; include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); ?></td>
         </tr>
         <!-- DWD Contribution End. !-->

         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
         <tr>
           <td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>
         </tr>
       </table></td>
     </tr>
   </table></td>

 

Before changes (lines 300..314):

          <tr>
           <td class="main"><?php echo tep_customer_greeting(); ?></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
         <tr>
           <td class="main"><?php echo TEXT_MAIN; ?></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
         <tr>
           <td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>
         </tr>

 

After changes (lines 307..331):

          <tr>
           <td class="main"><?php echo tep_customer_greeting(); ?></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
         <tr>
           <td class="main"><?php echo TEXT_MAIN; ?></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>

         <!-- DWD Contribution -> Add: Browse by Categories v2.0. !-->
         <tr>
           <td><br><?php include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); ?></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
         <!-- DWD Contribution End. !-->

         <tr>
           <td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>
         </tr>

Link to comment
Share on other sites

This is my code (Lines 127..143)

?>
             </tr>
           </table></td>
         </tr>
        <!-- DWD Contribution -> Add: Browse by Categories v2.0. !-->
         <tr>
           <td><?php $browse_category_id = $current_category_id; include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); ?></td>
         </tr>
         <!-- DWD Contribution End. !-->
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
         <tr>
           <td><?php include(DIR_WS_MODULES . FILENAME_FEATURED); ?></td>
         </tr>
       </table></td>
     </tr>
   </table></td>

 

(lines 318..339)

          <tr>
           <td class="main"><?php echo tep_customer_greeting(); ?></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
         <tr>
           <td class="main"><?php include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFINE_MAINPAGE); ?></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
        <!-- DWD Contribution -> Add: Browse by Categories v2.0. !-->
         <tr>
           <td><br><?php include(DIR_WS_MODULES . FILENAME_BROWSE_CATEGORIES); ?></td>
         </tr>
         <tr>
           <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
         </tr>
         <!-- DWD Contribution End. !-->
         <tr>
           <td><?php include(DIR_WS_MODULES . FILENAME_FEATURED); ?></td>
         </tr>

 

I' m getting crazy! I must have your contribution in my site!

 

Thank You.

Link to comment
Share on other sites

Download contribution: Browse by Categories

Version: 2.1

osCommerce: 2.2-MS1/MS2

Kudos: Gustavo Barreto - Main Categories v1.0b.

 

This release adds a minor database setting, which enables the sub-category links to be positioned either on the right side of the main category or below it. It adds to configuration group ID 101 a new entry: POSITION_SUB_CATEGORIES. This entry can be set to "right" or "bottom".

 

Other changes were splitting the table cell in odd and even columns or rows, depending if the POSITION_SUB_CATEGORIES is set to "right" or "bottom".

 

To update previous installations, just overwrite browse_categories.php in /catalog/includes/modules and execute this SQL Statement:

INSERT INTO configuration (
 configuration_title, configuration_key, configuration_value,
 configuration_description,
 configuration_group_id, sort_order, set_function, date_added
) VALUES
 ('Sub Category Links Position', 'POSITION_SUB_CATEGORIES', 'right',
   'Display Sub Categories on the right or at the bottom of Main Category?',
   '101', '5', 'tep_cfg_select_option(array(\'right\', \'bottom\'), ', now());

Link to comment
Share on other sites

Sorry Strainer, i can't post an image.

I have the standard subcategories icons on the top of the page and after the module box of Browse by Categories. All works fine. Ii ve just installed the 2.1 version of your contribution on milestone 2 Ms2 but...i cant understand how found the right way to escape by this situation...mybe i can erase the standard subcategories in the index but how can i do this?

 

 

Thank You.

Link to comment
Share on other sites

tuca,

 

To see if I finally got it on the main page everything is fine, since you see the content box with the top level categories and their sub-categories. Then, after you click on one of those top-level categories the new page that is presented to you has the "old" sub-category icons on top and beneath them the new content box with the same icons.

 

If that's the case, then you must comment out the lines 99 to 109, as this:

Before changes:

    $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";
     }
   }

 

After changes:

/*
   $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";
     }
   }
*/

 

I apologize for all this, I forgot to mention in the install instructions to comment out this part of the code.

Link to comment
Share on other sites

Spaceboy,

 

Thanks for this added featured. Do you have some screenshots or a demo site for us to view this change?

 

For what I've seen, you've added a new entry to configuration table, but not the configuration group ID 101 (Browse by Categories). I can easily add this new setting to the 101 group and update the documentation accordingly, if other users see it as a benefit.

 

I never thought of adding the sub-category products count, and in my experience the text with sub-categories title is rather long to have anything else appended to it. Sure is a nice feature to have, though.

 

I still have some pending code to add, such as improving the way the sub-category links are built. Currently, the code uses tables instead of more suited CSS lists, and the appearance isn't nice, when the position of sub-category links is set to "bottom".

 

Once again, thanks for using and evolving this small contribution.

Link to comment
Share on other sites

1. REQ new option : would it be possible to add an option to have ami x between

catalog-option-image-sub-2.jpg and catalog-option-text-sub-2.jpg

 

that mean an image at left and at right , the main category and under the subcategories

 

2.I got several problemes:

 

a. if there is for certains categories no sub categories and for other one yes , the there is a visual wrong ajustement , i m gonna try to post a screenshot.

the red is intended to show the TD ...

so as u can see the category iamge "CAMESCOPE" has no sub category so the "ECRANS" one is juste right to it ... while logically it should be one blank TD after to be just beyond the "SCANNERS" category image ...

 

rowpbe.jpg

 

b.if i have serveral sub categories and i broswe deeper , when i click on back to the top category , i doesnt go a top , it stays in it ... it refers to the function using

TEXT_BROWSE_PARENT_CATEGORY

MS2

Link to comment
Share on other sites

if someone wanna test i have well advanced , the 3rd choice works ...

i can make a zip

 

i got problem changing that :

 

* how can i change the >> by an image or another caracter , like one chosen form the admin, i dont find the line in the code code

 

* in the previous main category contribution , we could choose the width of the left TD , is there any advice , to be able to choose that in the code ? my aim is to put a background in the left TD with the category image and have the sub ctegories TD more close to the image

MS2

Link to comment
Share on other sites

azer and Spaceboy,

 

Great that you're working on v2.4, azer. Have you included the updated code from spaceboy, that he posted as v2.3? If not, I propose to take your updated and Spaceboy's updated code and merge it all in a new release. I must update the documentation, and I know how much of a pain that can be. Besides that, I need to also extend the kudos list with your names and e-mail addresses, if you both agree with it.

 

About problems, lemme see if I caught them all:

  • Fix blank table cell when category has no sub-categories.
  • Fix back link from 3rd level categories to 2nd level category.
  • Allow sub-category bullet character to be set from administration (configuration settings).
  • Allow more control on table cell width.

I'm sorry, I didn't quite understand what you meant with your request for "ami x between ...".

 

The table cell width is set for all cells, by calculating the correct percentage value based on maximum number of categories per row. The cell spacing and padding are also fixed, without any control except re-coding the module. Same thing happens with bullet link, although all these can be easily tweaked to accept settings from configuration table.

 

Please, reply me with your status, and I will set the tasks I need to be executed before releasing a new version. I don't mean to be a prick, I just want to have the contribution "stable" both in terms of features and in terms of documentation. I release new versions through a SourceForge project, but I don't know if it's "correct" to advertise it here. If I don't get an answer from both of you before 1pm today (GMT timezone), I'll start coding those fixes after that time.

 

I also have a demo site, based on osCommerce 2.2 MS1, where I can show-off new features. But this site isn't suited for testing or debugging purposes. Nevertheless, I can easily setup a new site, based on osCommerce 2.2 MS2, for us to test and have access to the administration part. Tell me if this suits your needs.

 

Thanks.

Link to comment
Share on other sites

azer and Spaceboy,

 

I have the code tested and ready for being packaged as contribution Browse by Categories v2.4, according to your bug and feature requests. I would like, if possible, to have the french language included in this new release, azer. You think it's possible?

 

I'll wait till 4pm (GMT timezone) for you two to reply me about including your nicks/names and e-mail addresses, about french translation and about code changes to fix or patch previous version. I would also like to include you and others as developers on the SourceForge project, if you wish.

 

Thanks.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...