wiecek Posted December 1, 2010 Posted December 1, 2010 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.
derben Posted December 5, 2010 Posted December 5, 2010 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
wiecek Posted December 5, 2010 Author Posted December 5, 2010 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.
derben Posted December 5, 2010 Posted December 5, 2010 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
derben Posted December 6, 2010 Posted December 6, 2010 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
ErikMM Posted December 6, 2010 Posted December 6, 2010 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 a-how-to-road-map 2.3.x road-map-for-the-newbies design basics how to make a horrible osC site ssl-how to updated-security-thread Web Developer, Firebug, and Notepad++ are powerful free tools for web design.
derben Posted December 7, 2010 Posted December 7, 2010 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
wiecek Posted December 7, 2010 Author Posted December 7, 2010 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!
ErikMM Posted December 8, 2010 Posted December 8, 2010 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'? a-how-to-road-map 2.3.x road-map-for-the-newbies design basics how to make a horrible osC site ssl-how to updated-security-thread Web Developer, Firebug, and Notepad++ are powerful free tools for web design.
Rubin Remus Posted December 8, 2010 Posted December 8, 2010 I could do with an answer to this one too. Cheers.
derben Posted December 11, 2010 Posted December 11, 2010 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
ErikMM Posted December 11, 2010 Posted December 11, 2010 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 a-how-to-road-map 2.3.x road-map-for-the-newbies design basics how to make a horrible osC site ssl-how to updated-security-thread Web Developer, Firebug, and Notepad++ are powerful free tools for web design.
derben Posted December 12, 2010 Posted December 12, 2010 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
wiecek Posted December 12, 2010 Author Posted December 12, 2010 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.
ErikMM Posted December 12, 2010 Posted December 12, 2010 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." a-how-to-road-map 2.3.x road-map-for-the-newbies design basics how to make a horrible osC site ssl-how to updated-security-thread Web Developer, Firebug, and Notepad++ are powerful free tools for web design.
wiecek Posted December 12, 2010 Author Posted December 12, 2010 '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.
casaba Posted February 5, 2011 Posted February 5, 2011 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.
casaba Posted February 5, 2011 Posted February 5, 2011 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?
KaoszNagymester Posted February 19, 2011 Posted February 19, 2011 Hi! I use OSC 2.3.1, but for me don't work this solution. :(
phpimran Posted May 3, 2011 Posted May 3, 2011 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..
phpimran Posted May 3, 2011 Posted May 3, 2011 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..
awicks Posted April 13, 2012 Posted April 13, 2012 //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
awicks Posted April 13, 2012 Posted April 13, 2012 I have managed to get what I was after working by using this module: http://addons.oscommerce.com/info/8384/v,23 Have tweaked it slightly to improve the HTML / CSS structure but that is all I have changed.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.