Sign in to follow this  
Followers 0
straider

Browse by Categories

191 posts in this topic

Download contribution: Browse by Categories

Version: 2.4

osCommerce: 2.2-MS1/MS2

Kudos:

This new release fixes the bugs pin-pointed by "azer" and adds new features requested and coded by "azer" and "Spaceboy":

  • The bullet prefix for sub-category links is now defined through the configuration table, using the setting BULLET_BROWSE_SUB_CATEGORIES. This setting, by default is "?", can be set to any alfanumeric prefix by the administrators.
  • The sub-category links can now, optionally, display a products count for each sub-category. It's set through the configuration table using the setting DISPLAY_SUB_CATEGORIES_COUNT, which by default is set to 'true'. This sufix has the format specified by "Spaceboy": sub-category-text-link (product_count).
  • Categories with empty sub-categories list (categories without any sub-category) don't disrupt the table layout inside the content box anymore. The fix now checks if either the list is empty and the setting DISPLAY_BROWSE_SUB_CATEGORIES is enabled. If so, then a blank table cell is shown.
  • The parent category of deeper sub-categories (3rd level or more) is now set in the correct manner, does allowing the parent category link to be fully functional. Another bug, related to this one, has been fixed, which would cut of from the breadcrum trail the top level categories besides current category and parent category.
  • Other minor bugs were fixed: the variable named $cPath was changed to $cPath_cur and the list of sub-category links is now properly reset outside the building loop.

To update previous installations, download the new release, overwrite the old file browse_categories.php in the location /catalog/includes/modules with the new one and execute the following SQL statement:

/* DWD Contribution: Browse by Categories v2.4. */
INSERT INTO configuration (
 configuration_title, configuration_key, configuration_value, configuration_description,
 configuration_group_id, sort_order, set_function, date_added
) VALUES
 ('Sub Category Links Bullet', 'BULLET_BROWSE_SUB_CATEGORIES', '?', 'Select Bullet character to prefix each Sub Category Link', '101', '6', null, now()),
 ('Display Sub Category Products Count', 'DISPLAY_SUB_CATEGORIES_COUNT', 'true', 'Display how many products does a Sub Category have?', '101', '7', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now());
/* DWD Contribution End. */

Share this post


Link to post
Share on other sites

azer,

 

I think I understand what you mean, now. Your request is to make it look more like Main Categories:

  • Left Side - Current Level Category Image/Text.
  • Right Side - Current Category Title and List of Sub-Category Links.

Should the Category Title be also clickable, like the image/text on the left side?

 

Besides that, in terms of logic:

  • If category link type is set to 'text', then no category title should be displayed.
  • If category link type is set to 'image', then category title is to be displayed as well, according to configuration settings. These settings will select either "current" display mode or this new requested mode.
  • If the sub-category links list position is set to 'bottom', then the category title should be displayed beneath the image and centered (as it is), with the sub-category links list below it.
  • Table cell width should be either set through "current" calculation or use value set in the configuration table. This width is to be set for left or right side or both?
  • Table cell spacing and padding should be set through configuration table settings.

While the first bullet points present no challenges, just some more coding, the last two bullet points raise some questions:

  • By allowing administrators to control table cell width from configuration table settings this can cause some confusion and layout disruption for non-technically savvy people. IMHO, I find it best to have the width being calculated automatically, instead of allowing more thin control over it. Check lines 191..196 that set $table_cell_width variable.
  • Also, the width is currently set uniform for all cells, there's no distinction between left or right side. This works better for my layouts, although I see a point in having thinner right sides against bigger category images or having thinner left sides against widder sub category titles. This can be fixed by simply removing the width control from the array 'params' of content_box, in lines 202, 207, 220 and 234. It may prevent the full table from being centered on content box, though, although I'm not sure since I didn't test this.
  • To end, I'm not aware of how to have a thin control over content box table cell spacing and padding. Maybe it's necessary to code a new "tweaked content box", just for Browse by Categories, which I don't find it suited for the purpose of this contribution. If there's an easy way to set the cellspacing and cellpadding either through content box array 'params' or through CSS then this would indeed be a neat feature. I'll see if one of these cases is possible and I'll report it later.

I'm under the impression that using CSS lists to build the sub-category links layout would be much smarter, allowing for more effects and more control on both the left and right/bottom sides. Does anyone want to comment on this? I've read somewhere that having different styles for category icon and sub-category links would be a nice feature to have, although I don't recall exactly where I've read it. This can be a new feature for upcoming release.

Share this post


Link to post
Share on other sites

Feature Request List:

  • Choose from Browse by Categories mode and Main Categories mode. This last mode has been requested by "azer", while the first mode is the current mode. By mode please understand how the category title should be displayed: either below the image or on top of sub-category links list.
  • Apply new CSS classes to each table cell, allowing different effects and styles for category icon (image or text) and sub-category links.
  • Add French translation.
  • Use sub-category products count formatted string, instead of hard-coded format (current format proposed and coded by "Spaceboy"). If this new setting SUB_CATEGORIES_COUNT_FORMAT, that should replace DISPLAY_SUB_CATEGORIES_COUNT, is empty then don't display products count else display count using setting value. As examples, this new setting could be set to either (%d) or -> %d or = %d.

Please, feel free to extend this list with your own requests.

Share this post


Link to post
Share on other sites

sorry it took me so long time to answer but i live in france and couldnt get on the forum before 8pm !

 

im gonna read all ur messages and check the 2.4 code ... il then make again all my changement with the new feature i wanted to add ... and then i can send a zip for you to test it .. i ll also add a french translation with a new french sql also

 

please try to contact me by msn : maps1234 @ hotmail.com or icq : 30885852 and we would be able to work easier together

Share this post


Link to post
Share on other sites

proposal :

 

azer 1. change the variable name of the cofiguration in the admin to all begin by the same terms for instance :

 

SUB_CATEGORIES_COUNT_FORMAT by BCAT_SUBCAT_COUNT_FORMAT

DISPLAY_SUB_CATEGORIES_COUNT by BCAT_DISPLAY_SUBCAT_COUNT

 

cos when u use some soft to configure with mysql the configuration, it is easier to sort the variable by name and so regroup all the one that are used by BCAT (broswe by Categories)

Share this post


Link to post
Share on other sites

azer,

 

Great idea.

 

Although I'm starting to think that the variable names are too big, but at least they do tell what they mean. In any case, wouldn't it be enough to watch variables having group ID equal to 101, instead of checking all variables in the configuration table?

 

Thanks.

Share this post


Link to post
Share on other sites

thanks for the work of jose , im gonna begin the french transaltion for the release of the next version ...

Share this post


Link to post
Share on other sites

jose , here are the bugs i still have after the last file u sent me correcting the 2 bugs :

 

i give screenshots

 

1.with image only , i dont have the caption main category + sub cat on the right

 

imgonly.jpg

imgonlyb.jpg

 

2.like i wrote u in my email there is still a problem with the cell sizes not equal , on my screenshot u can see it !

 

cellsize.jpg

cellsize.jpg

cellsizeb.jpg

Share this post


Link to post
Share on other sites

azer,

 

I've fixed those two bugs.

 

Find in /catalog/includes/modules/browse_categories.php

        $sub_category_links = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_cur, 'NONSSL') . '"><b>' .
                             $current_category_name . '</b></a><br>';

Replace it with

        $sub_category_links = '<a href="' . tep_href_link(FILENAME_DEFAULT, $cPath_cur, 'NONSSL') . '"><b>' .
                             $current_category_name . '</b></a><br>' . $sub_category_links;

 

This takes care of your bug tracking #1, which now properly displays the category icon with an image only and on the right the category name with the sub-category links.

 

Find in /catalog/includes/modules/browse_categories.php all occurrences of

'text'   => ($sub_category_links == '' && BRWCAT_SUBCAT_MODE == 'true') ? ' ' : $sub_category_links);

Replace all of them with

'text'   => ($sub_category_links == '' && BRWCAT_SUBCAT_MODE != 'off') ? ' ' : $sub_category_links);

 

Thanks so much of all your efforts, in tracking these nasty bugs. :)

Share this post


Link to post
Share on other sites

Please, everyone,

 

Bare in mind that azer and I are coding Browse by Categories v2.5, which will have several new features and a more tweaked coded. This code has yet not been released, we're finalizing the package for the contribution and as soon as it's ready either azer or I will make it available to the community.

 

The screenshots that azer has posted show some of those nice features, and we're fixing the bugs we've found so far. The database settings have changed, which will require a new SQL script, and the language dependant defines are no longer edited in the top language file, rather are set inside a new file, located at /catalog/includes/languages/<language>/browse_categories.php. There are now 3 languages supported by this contribution: english, portuguese and french.

 

Anyone else that wants to translate to their native language, please download the contribution v2.5, edit the file under /catalog/includes/languages/english/browse_categories.php (or any one of the other two) and post it here, I will then included in the next release. Or if you wish, simply add the translated file to the contribution package and I'll include it on the next release as well.

 

Thanks to everyone, namely spaceboy and azer.

Share this post


Link to post
Share on other sites

the bug #1 is fixed !

 

sorry but for me :

Replace all of them with

 

CODE 

'text'  => ($sub_category_links == '' && BRWCAT_SUBCAT_MODE != 'off') ? ' ' : $sub_category_links);

 

didnt change anything , is it for the Bug #2 , meaning cell size bug ?

 

 

also i found bug 3:

 

for subcategory product count , instead of giving the numbers , it add "on" or "off" at the end of the category name as you can see on my previous screenshots

Share this post


Link to post
Share on other sites

azer,

 

Yes, that code fixes Bug #2. This bug tracking reminds me that we should use the sourceforge project bug tracking services, it should help all of us post bug reports and bug fixing. The blank cell bug happens when sub-category links are empty and the sub-category link mode is not off. For what I've tested, cell width bug is related to this blank cell bug. Please, advise if my assumption is incorrect.

 

The SQL code has a bug (Bug #3), I don't know if I sent you the latest script. If you use PHPMyAdmin, please edit the variable BRWCAT_SUBCAT_COUNTS and click on set_function to NULL, which will replace the old setting tep_cfg_select_option with on/off options that I used on an old code review.

 

Thanks.

Share this post


Link to post
Share on other sites

bug 3 : i cant remove the set-function value , if i do it :

 

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in c:\program files\easyphp\www\rc\admin\configuration.php(119) : eval()'d code on line 1

 

so i should let that or not ?:

'tep_cfg_select_option(array(\'off\', \'on\')

Share this post


Link to post
Share on other sites

here is the last sql file i have ::

 

INSERT INTO configuration (
 configuration_title, configuration_key, configuration_value, configuration_description,
 configuration_group_id, sort_order, set_function, date_added
) VALUES
 ('Category Icon Mode', 'BRWCAT_ICON_MODE', 'image with caption', 'Choose between Disabled, Text and Image without or with Caption for Current Level Categories Icons.<br /><b>Note</b>: Image Only mode causes the category name to be displayed on top of its sub-category links.', '101', '1', 'tep_cfg_select_option(array(\'off\', \'text\', \'image only\', \'image with caption\'), ', now()),
 ('Sub-Category Link Mode', 'BRWCAT_SUBCAT_MODE', 'right top', 'Choose between Disabled, Bottom or Right position of Sub-Category Links.', '101', '2', 'tep_cfg_select_option(array(\'off\', \'bottom\', \'right top\', \'right middle\', \'right bottom\'), ', now()),
 ('Max number of category Icons per Row', 'BRWCAT_ICONS_PER_ROW', '2', 'Choose how many Current Level Categories to display per row.', '101', '3', null, now()),
 ('Sub-Category Links Bullet', 'BRWCAT_SUBCAT_BULLET', '?', 'Select Bullet character to prefix each Sub Category Link.', '101', '4', null, now()),
 ('Sub-Category Products Count', 'BRWCAT_SUBCAT_COUNTS', '', 'Define sprintf format to display Sub-Category Products count.<br /><b>Note</b>: Default format is (%s) that causes the products count to be displayed surrounded by parentesis. For more information, read the PHP manual for sprintf function.', '101', '5', 'tep_cfg_select_option(array(\'off\', \'on\'), ', now()),
 ('Category Name Case', 'BRWCAT_NAME_CASE', 'same', 'Choose between same case, upper case, lower case or title case for Current Level Categories Name.', '101', '6', 'tep_cfg_select_option(array(\'same\', \'upper\', \'lower\', \'title\'), ', now());
/* DWD Contribution End. */

Share this post


Link to post
Share on other sites

Bug 3 : i changed the sql for set function to

tep_cfg_select_option(array('(%s)', '%s','- %s'),

 

and now it works , we should like you said update the sql install txt

Share this post


Link to post
Share on other sites

azer,

 

The new SQL scripts are fixed. The code you must remove is:

'tep_cfg_select_option(array(\'off\', \'on\'), '

And instead use this:

null

 

But about Bug #2, I've managed to create the same conditions as yours, which indeed reveal a wrong presentation of the categories. I'll fix it ASAP. In the meantime, try to use sort codes on each category, and check that the bug while still existing doesn't cause any disruption.

 

Thanks.

Share this post


Link to post
Share on other sites

The cause for Bug #2 seems to be not full handling the case where a category has empty sub-categories list. Specially, if the category is the first one, then the layout is totally disrupted.

 

I had to seek why the code wasn't fully handling the case of when first categories have no sub-categories. At first it seems the bug was for image onyl mode, but thanks once more to azer, the bug exists for both modes: image only and image with caption.

 

I've found out the problem, the code

 $arr_sub_category_mode = explode(' ', BRWCAT_SUBCAT_MODE);

that is inside the while loop must be moved to before the while loop. This is necessary because the code that sets the correct table cell width relies on $arr_sub_category_mode[0] being compared to the value 'right', after the while loop. This while loop only runs when there are sub-categories for the current category.

 

I've tested the code on the demo site for doCommerce, and everything seems fine now.

Share this post


Link to post
Share on other sites

Download contribution: Browse by Categories

Version: 2.5

osCommerce: 2.2-MS1/MS2

Kudos:

  • azer - Special thanks for his bug tracking efforts and french translation.

This new release has major new features:

  • The former database variables have been fully replaced by 6 new ones, that helped optimized the code to offer easier maitenance. These new variables belong to group ID 101 and are:
    • BRWCAT_ICON_MODE - to either disable the content box from being displayed or to set the icon mode as either text or as image with or without caption.
    • BRWCAT_SUBCAT_MODE - to either disable displaying the sub-categories of a category or to set the position of the sub-category links relative to the category icon.
    • BRWCAT_ICONS_PER_ROW - that must be set to the number of maximum categories to display in a row.
    • BRWCAT_SUBCAT_BULLET - to set the sub category links bullet.
    • BRWCAT_SUBCAT_COUNTS - that must be set with a proper PHP sprintf format string in order to display the products count of each sub-category.
    • BRWCAT_NAME_CASE - that sets how the category name should be displayed.

    [*]Several bugs were fixed, with the very helpful support of azer, that now allow for a very flexible and easy layout setting:

    • The category icon can have the image caption below the image or just the image, in which case the category name is shown on top of its sub-category links.
    • The sub-category links can be vertically aligned to the top, middle or bottom of the category icon.
    • The category name can be in uppercase, lowercase, title case or not changed at all.
    • The product count is now a format, compliant with PHP sprintf function, to easier suit the online administrator needs.
    • Finally, the text strings are no longer defined inside the top language file, but inside a new file that is kept on each language location. As a plus, azer as contributed with the french translation.

To update previous installations, download the new release, overwrite the old file browse_categories.php in the location /catalog/includes/modules with the new one, copy the new browse_categories.php files to the location /catalog/includes/languages/<language> and execute the following SQL statement:

/* DWD Contribution: Browse by Categories v2.5. */
DELETE FROM configuration WHERE configuration_key in (
 'DISPLAY_BROWSE_CATEGORIES', 'BROWSE_CATEGORIES_TYPE', 'DISPLAY_BROWSE_SUB_CATEGORIES', 'MAX_BROWSE_CATEGORIES_PER_ROW',
 'POSITION_SUB_CATEGORIES', 'BULLET_BROWSE_SUB_CATEGORIES', 'DISPLAY_SUB_CATEGORIES_COUNT'
);

INSERT INTO configuration (
 configuration_title, configuration_key, configuration_value, configuration_description,
 configuration_group_id, sort_order, set_function, date_added
) VALUES
 ('Category Icon Mode', 'BRWCAT_ICON_MODE', 'image with caption', 'Choose between Disabled, Text and Image without or with Caption for Current Level Categories Icons.<br /><b>Note</b>: Image Only mode causes the category name to be displayed on top of its sub-category links.', '101', '1', 'tep_cfg_select_option(array(\'off\', \'text\', \'image only\', \'image with caption\'), ', now()),
 ('Sub-Category Link Mode', 'BRWCAT_SUBCAT_MODE', 'right top', 'Choose between Disabled, Bottom or Right position of Sub-Category Links.', '101', '2', 'tep_cfg_select_option(array(\'off\', \'bottom\', \'right top\', \'right middle\', \'right bottom\'), ', now()),
 ('Max number of category Icons per Row', 'BRWCAT_ICONS_PER_ROW', '2', 'Choose how many Current Level Categories to display per row.', '101', '3', null, now()),
 ('Sub-Category Links Bullet', 'BRWCAT_SUBCAT_BULLET', '?', 'Select Bullet character to prefix each Sub Category Link.', '101', '4', null, now()),
 ('Sub-Category Products Count', 'BRWCAT_SUBCAT_COUNTS', '(%s)', 'Define sprintf format to display Sub-Category Products count.<br /><b>Note</b>: Default format is (%s) that causes the products count to be displayed surrounded by parentesis. For more information, read the PHP manual for sprintf function.', '101', '5', null, now()),
 ('Category Name Case', 'BRWCAT_NAME_CASE', 'same', 'Choose between same case, upper case, lower case or title case for Current Level Categories Name.', '101', '6', 'tep_cfg_select_option(array(\'same\', \'upper\', \'lower\', \'title\'), ', now());
/* DWD Contribution End. */

Share this post


Link to post
Share on other sites

Hi,

 

I've installed the new version of Browse by categories.

Thanks a lot for this usefull mod !

 

See this page :

www.18carati.com/catalog/default.php?cPath=4&language=en

 

This is my little problem though:

How do I avoid the sub-categories to display twice in the centre of page ?

 

Thanks

Share this post


Link to post
Share on other sites

tomcat,

 

In your default.php (MS1) you have commented out the default sub-category icons of osCommerce, by following the comments for Browse by Categories. Then, you added the code that calls the Browse by Categories module. So far so good.

 

But after that, you still have the same code again that was commented out several lines before. I assume you either had two-sub-category icons before or that instead of commenting out the code you added it before.

 

Meaning, take a closer look at the comments for the default.php and check the differences from default.php.bak that are included in the contribution package. When the comment as -> Add: it means you must copy from the contribution PHP file to your default osCommerce PHP file. But when it has the comment -> Remove: or -> Change: it means you must either comment out the code between //DWD tags in your original PHP file or that you must make some changes to the lines between the same tags.

 

Short reply: Remove the equivalent lines after the code that calls the Browse by Category module by comparing them to the lines before that call that were removed.

 

Does this help at all?

Share this post


Link to post
Share on other sites

happy to see that this new release is done ! and happy to have a new buddy on osc :)

 

we need also to know if it works under MS2 , give us feedback

Share this post


Link to post
Share on other sites

azer,

 

Should work fine on MS2. I've tested it on my original MS2 installation, and everything is as with MS1. If anyone has any problems, please report them here and I'll try to help sort them out.

 

Thanks.

Share this post


Link to post
Share on other sites

azer, tomcat, spaceboy et al,

 

Now, about new features, you care to start a listing of the feature requests, sorted by priority of need?

 

I'd like to see samples of osCommerce installations (MS1 or MS2) running Browse by Categories. I'm thinking more on how to have the code ready for special visual effects or different layout needs. As it stands, latest version is well suited for my needs, and I assume your needs as well azer. Does anyone else want new features, or should we leave this contribution as it is and only do bug fixing?

 

If no one says otherwise, I plan to just do minor bug fixes on this code, at least in the near future. Another important aspect is to have a standard or osCommerce compliant installation instructions, maybe an INSTALL.TXT or install-contribution.txt, with step-by-step procedures. Did someone have any difficulties in installing the contribution? What would have been better to make the installation process easier or simpler?

 

Thanks.

Share this post


Link to post
Share on other sites

Help!!

 

I think this contrib, is exactly what I want. However I keep getting errors when tring to use it.

Warning: Division by zero in /hsphere/local/home/soloente/swissgoatmilksoap.com/catalog/includes/modules/browse_categories.php on line 208

 

this is line 208:

 

$table_cell_width = (100 / BRWCAT_ICONS_PER_ROW) . '%';

Whats wrong here?

 

I have a feeling I need to do something to SQL, but I couldnt figure it out from the readme.

 

www.swissgoatmilksoap.com/catalog

 

BTW: I tried using the MS1 and MS2 files. Neither works. Although the MS1 files give a blank screen with mysql errors. MS2 files just gives the errors but shows the rest of the page and everything else works, so I assume I have MS2, just some issues with my configuration.

 

The readme says that you can change stuff in the admin under configuration? Where?

 

Thanks in advance

Edited by yan

Share this post


Link to post
Share on other sites

Sorry guys, I got it!!

 

Used phpMyadmin to run the query. I was worried Id mess something up, then decided to just go for it. Works great!!

 

Now I just need to format the way it looks inside the category box.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0