Jump to content

Archived

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

wiecek

Show all subcategories in box module for 2.3.1

Recommended Posts

I'm trying to figure out how to show all the subcategories for all the categories in the box module for version 2.3.1.

 

Right now, it only shows the subcategories for the selected category. I'd like it to show whether or not it is highlighted. There are contribs that do this for previous OScommerce versions, but if there's an easy way to do this with the new version module, that'd be nice.

 

Thanks all.

Share this post


Link to post
Share on other sites

index.php

line 37

Change:  if ($category_depth == 'nested') {
To:      if ($category_depth == 'nested' && isset($HTTP_GET_VARS['cPath'])) {

 

application_top.php

line 437

Ch:  $cPath = '';
to:  $cPath = '22';

 

 

the second change forces the default to be show all categories.

the first change allows the default home page while showing all folders.


-Colin

www.ColinGlover.com

Share this post


Link to post
Share on other sites

Derben, thank you, this is a step in the right direction, but not exactly what I wanted to do.

 

With your mod, the homepage will default to the category 22. But I would like categories 22 and 23 open on the homepage.

 

Further, I'd like those categories open to show their subcategories through out the entire site.

 

But for now, your mod is nice, clean and simple. And gets me about half way to where i want to be. Thank you.

Share this post


Link to post
Share on other sites

I only have one cat. (22) filled :P so it worked for me fine. But yes if you have more cats.. it will possibly require programming to loop through them all.


-Colin

www.ColinGlover.com

Share this post


Link to post
Share on other sites

How about:

 

/includes/modules/boxes/bm_categories.php

 

around line 99

Find:   $parent_id = $categories['categories_id'];
Add:    $dbs[] = $categories['categories_id'];

 

around line 109

change:   while (list($key, $value) = each($cPath_array)) {
to:       while (list($key, $value) = each($dbs)) {

 

 

PS: one is an addition, and one is a change.


-Colin

www.ColinGlover.com

Share this post


Link to post
Share on other sites

How about:

 

/includes/modules/boxes/bm_categories.php

 

around line 99

Find:   $parent_id = $categories['categories_id'];
Add:    $dbs[] = $categories['categories_id'];

 

around line 109

change:   while (list($key, $value) = each($cPath_array)) {
to:       while (list($key, $value) = each($dbs)) {

 

 

PS: one is an addition, and one is a change.

 

This worked great on all pages, EXCEPT the "home" page (catalog)

 

thank you


Web Developer, Firebug, and Notepad++ are powerful free tools for web design.

Share this post


Link to post
Share on other sites

This worked great on all pages, EXCEPT the "home" page (catalog)

 

thank you

 

you need to combine both fixes I mentioned :) all 4 lines.


-Colin

www.ColinGlover.com

Share this post


Link to post
Share on other sites

This actually worked perfect for me.

 

ErikMM, if you make the change to application_top.php to set the cPath to on of your categories, then it should work for your homepage as well.

 

Thanks, derben!

Share this post


Link to post
Share on other sites

you need to combine both fixes I mentioned :) all 4 lines.

 

1. index.php ~line 37

Change:  if ($category_depth == 'nested') {
To:      if ($category_depth == 'nested' && isset($HTTP_GET_VARS['cPath'])) {

2. catalog/application_top.php ~line 437

Ch:  $cPath = '';
to:  $cPath = '22';

3. includes/modules/boxes/bm_categories.php ~around line 99

Find:   $parent_id = $categories['categories_id'];
Add:    $dbs[] = $categories['categories_id'];

4.includes/modules/boxes/bm_categories.php ~around line 109

change:   while (list($key, $value) = each($cPath_array)) {
to:       while (list($key, $value) = each($dbs)) {

 

What goes in place of the '22'?


Web Developer, Firebug, and Notepad++ are powerful free tools for web design.

Share this post


Link to post
Share on other sites

1. index.php ~line 37

Change:  if ($category_depth == 'nested') {
To:      if ($category_depth == 'nested' && isset($HTTP_GET_VARS['cPath'])) {

2. catalog/application_top.php ~line 437

Change:  $cPath = '';
to:  $cPath = '22';

3. includes/modules/boxes/bm_categories.php ~around line 99

Find:   $parent_id = $categories['categories_id'];
Add:    $dbs[] = $categories['categories_id'];

4.includes/modules/boxes/bm_categories.php ~around line 109

change:   while (list($key, $value) = each($cPath_array)) {
to:       while (list($key, $value) = each($dbs)) {

 

What goes in place of the '22'?

 

Where does it say to change a 22? Change the default '' (nothing) to '22'. ;)

-DerBen


-Colin

www.ColinGlover.com

Share this post


Link to post
Share on other sites

Where does it say to change a 22? Change the default '' (nothing) to '22'. ;)

-DerBen

exactly...it seems it should not be 22, but something else per the conversation preceding my question..."what" is the question, What goes in place of the '22'? Back to default? ' ' ? Why so cryptic btw?

 

wiecek said "make the change to application_top.php to set the cPath to on of your categories, then it should work for your homepage as well"

 

this is also a little to cryptic for me as well-- call me dumb


Web Developer, Firebug, and Notepad++ are powerful free tools for web design.

Share this post


Link to post
Share on other sites

ErikMM ... ya lost me. No cryptics here, only 4 simple changes.

 

Just make the changes (all 4) exactly as I stated and it will work. I'm using it right now on my store, also it's confirmed by wiecek when he said it worked perfect for him too.


-Colin

www.ColinGlover.com

Share this post


Link to post
Share on other sites

Yes, works well.

 

Only problem that I've encountered is that when you are on the page listing a nested category, category 22 becomes bold as well as the current nested category. But that's a relatively minor style issue.

Share this post


Link to post
Share on other sites

Yes, works well.

 

Only problem that I've encountered is that when you are on the page listing a nested category, category 22 becomes bold as well as the current nested category. But that's a relatively minor style issue.

I played with different numbers, 22, 1, 2, 3, 50 etc. (for change #2 sited above). And I am having the bold issue as well on the home page. However, I'm kind of over it now, and like the home page cat menu collapsed...expanding after picking one of the mains and turning bold etc. on the destination page.

 

Thanks again for this tip despite a little confusion on my part as to why "22."


Web Developer, Firebug, and Notepad++ are powerful free tools for web design.

Share this post


Link to post
Share on other sites

'22' is just the id assigned to the first category that you create in oscommerce.

 

The reason that it's bold on the homepage is where the default category path on index.php is usually '' the change now makes it category '22' or whatever category that you want selected.

Share this post


Link to post
Share on other sites

Thanks for this one, Derben.

 

I think I found a solution to the Home or Catalog bold issue:

$cPath = '0';

 

So far, looks good for me: all categories expanded but nothing in bold.

Share this post


Link to post
Share on other sites

Never so simple.

 

Right now, I have two Categories, each with multiple subcategories.

 

Bold works fine when I select either Category or a subcategory within the first Category.

 

However, if I select a subcategory in the second Category, both Categories are displayed in bold.

 

(This is true even when I enter $cPath = '22';.)

 

Anybody else run into this? Any ideas?

Share this post


Link to post
Share on other sites

Also interested in such feature for 2.3.1

 

here is the code for showing subcategory by default in oscommerce 2.3.1...

you need to following in your bm_categories.php file ...

add this code below line number 94

 

//showing sub_category by default..

$subcategories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$categories['categories_id'] . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

//while ($subcategories = tep_db_fetch_array($subcategories_query)) {

$key=0;

 

while ($subcategories = tep_db_fetch_array($subcategories_query)) {

$tree[$subcategories['categories_id']] = array('name' => $subcategories['categories_name'],

'parent' => $subcategories['parent_id'],

'level' => $key+1,

'path' => $new_path . '_' . $subcategories['categories_id'],

'next_id' => false);

$tree[$parent_id]['next_id'] = $subcategories['categories_id'];

$parent_id = $subcategories['categories_id'];

$first_id = $subcategories['categories_id'];

 

}

//}

//end of sub_category by default link..

Share this post


Link to post
Share on other sites

Too bad this isn't resolved.

 

//showing sub_category by default..

$subcategories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$categories['categories_id'] . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

//while ($subcategories = tep_db_fetch_array($subcategories_query)) {

$key=0;

 

while ($subcategories = tep_db_fetch_array($subcategories_query)) {

$tree[$subcategories['categories_id']] = array('name' => $subcategories['categories_name'],

'parent' => $subcategories['parent_id'],

'level' => $key+1,

'path' => $new_path . '_' . $subcategories['categories_id'],

'next_id' => false);

$tree[$parent_id]['next_id'] = $subcategories['categories_id'];

$parent_id = $subcategories['categories_id'];

$first_id = $subcategories['categories_id'];

 

}

//}

//end of sub_category by default link..

Share this post


Link to post
Share on other sites

//showing sub_category by default..

$subcategories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$categories['categories_id'] . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");

//while ($subcategories = tep_db_fetch_array($subcategories_query)) {

$key=0;

 

while ($subcategories = tep_db_fetch_array($subcategories_query)) {

$tree[$subcategories['categories_id']] = array('name' => $subcategories['categories_name'],

'parent' => $subcategories['parent_id'],

'level' => $key+1,

'path' => $new_path . '_' . $subcategories['categories_id'],

'next_id' => false);

$tree[$parent_id]['next_id'] = $subcategories['categories_id'];

$parent_id = $subcategories['categories_id'];

$first_id = $subcategories['categories_id'];

 

}

//}

//end of sub_category by default link..

 

This mod has shown most of my subcategories. However, I have a couple of issues.

- My first category has subcategories, but these are not displayed (although I think this is related to the next issue)

- My subcategories appear above their respective categories in the categories list.

 

Any idea how to fix this?

 

Thanks

 

Andy

Share this post


Link to post
Share on other sites

×