Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / how to keep categories unfolded on sidebox?

how to keep categories unfolded on sidebox?

Views: 12,609

Results 1 to 20 of 43
14 Jul 2008, 1:47 AM
#1
sotlordrahl avatar

sotlordrahl

New Zenner

Join Date:
May 2008
Posts:
11
Plugin Contributions:
0

how to keep categories unfolded on sidebox?

This is how I hacked up the zen-cart code to have the ability to unfold ANY or ALL categories to display sub-cats on all pages, not just the index page:

open 'includes/classes/category_tree.php'

  1. change line 137

change

if (zen_not_null($cPath)) {

TO =>

if (zen_not_null($cPath) or 1) {


  1. insert code in lines 141-145

ORIGINAL

reset($cPath_array);

while (list($key, $value) = each($cPath_array)) {


insert =>

$cPath_array = array(#,#);

in between the reset and while commands.

equals the category ID you wish to be unfolded... you can have it only unfold one, or all... all would be #,#,#,#,# and so on until you have all the ID's inside the parenthesis.

END RESULT

reset($cPath_array);

$cPath_array = array(1,2,5,7);

while (list($key, $value) = each($cPath_array)) {


hope this helps some people, my buddy and I spent 2 hours trying to figure this one out. tried to add some hyphens in here for reading pleasure and such... do not insert the page breaks I made. ENJOY!!!

Any questions let me know, this is what worked for me.

15 Jul 2008, 1:22 AM
#2
so2006 avatar

so2006

New Zenner

Join Date:
Jul 2008
Posts:
17
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

How does it work?

16 Jul 2008, 4:17 AM
#3
sped1530 avatar

sped1530

New Zenner

Join Date:
Nov 2007
Posts:
37
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

I inserted what you had and only the 3rd cat was unfolded. Could you explain more about the id's or ###.

Thanks
Dave

18 Jul 2008, 2:31 AM
#4
qwert302 avatar

qwert302

Zen Follower

Join Date:
Mar 2008
Posts:
148
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

Huge pat on the back, thank you very much.

btw your line number were way different than mine, the code you speak of occurs starting on line 70 for me. I'm on 1.3.8, not sure if that is what the difference is but it still works great. Thanks.

19 Jul 2008, 1:47 AM
#5
sotlordrahl avatar

sotlordrahl

New Zenner

Join Date:
May 2008
Posts:
11
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

every category/subcat has an ID

example:

id : catname

1:shoes
-3:nike
-4:adidas
2:shirts

you can only 'unfold' categories with subcategories... it's not going to list products there... so in this instance, you would just use ID 1 there.... if shirts had subcats, you would include ID 2... and so on. only use cat IDs there with subcats inside there.

hope that helps...

1 Aug 2008, 6:11 PM
#6
dytron avatar

dytron

New Zenner

Join Date:
Feb 2008
Posts:
60
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

Qwert302:

btw your line number were way different than mine, the code you speak of occurs starting on line 70 for me. I'm on 1.3.8, not sure if that is what the difference is but it still works great. Thanks.

nice hack!!:smartalec: was looking for that and didnt want to add a mod for just a small change:clap:

I also had the lines of this code in different location, am using 1.3.8a here is my code starting from line 70-73;

if (zen_not_null($cPath) or 1) {  //addes this "or 1)" to always open subcategories
      $new_path = '';
      reset($cPath_array);
	  $cPath_array = array(15); // added this line to always open categorie #15 > subcategories 

Works great!:bigups:

18 Aug 2008, 6:46 PM
#7
eberline avatar

eberline

New Zenner

Join Date:
Aug 2008
Posts:
5
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

Thank you so much. I spent like 6 hours trying to find this!!!:D

22 Aug 2008, 8:01 PM
#8
kburner avatar

kburner

Totally Zenned

Join Date:
Apr 2008
Location:
Flint, Michigan
Posts:
684
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

Can you post a website we can view how it works?

Thanks,
Kim
:smile:

23 Aug 2008, 1:22 PM
#9
kburner avatar

kburner

Totally Zenned

Join Date:
Apr 2008
Location:
Flint, Michigan
Posts:
684
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

I can not get this to work.

Code starts on line70. I have version 1.3.8

if (zen_not_null($cPath) or 1) {
$new_path = '';
reset($cPath_array);
$cPath_array = array(82,83,84,111,112,113,114,115);
while (list($key, $value) = each($cPath_array)) {

I first tried my top category, but did not work. I went deeper into sub-category and still does not work.

Help!
Thanks,
Kim

25 Aug 2008, 12:04 PM
#10
kmvguy83 avatar

kmvguy83

New Zenner

Join Date:
Aug 2008
Posts:
19
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

Thank YOU!!!

This is what i wanted to do from the start.

i have 1.3.8a and i also had the line starting at 70

This should be faq'd

28 Aug 2008, 3:28 PM
#11
kburner avatar

kburner

Totally Zenned

Join Date:
Apr 2008
Location:
Flint, Michigan
Posts:
684
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

Thank you. I finally got it to work. But, I noticed that there is vertical line and underscore in front of the sub-category.

How do I get rid of it?

And I would only like the top category to unfold when clicked on...Is that possible?

Thanks again...Kim

https://www.burnerbooks.com/index.php

3 Sep 2008, 2:26 AM
#12
ve39 avatar

ve39

New Zenner

Join Date:
Sep 2008
Posts:
31
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

could any one host the category_tree.php
i'm messing up when trying ti edit it

and i guessing we have to upload it to /includes/modules/sideboxes

4 Sep 2008, 4:46 PM
#13
kburner avatar

kburner

Totally Zenned

Join Date:
Apr 2008
Location:
Flint, Michigan
Posts:
684
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

I still have not figured out how to get rid of the vertical line_ before my subcategories. Does anyone know how?

You can see it on my site: https://www.burnerbooks.com/index.php in the Shop by Categories sidebox. I am still modifying my stylesheets - the light blue is too pale. I will be changing that tonight.

Thanks,
Kim

4 Sep 2008, 7:49 PM
#15
kburner avatar

kburner

Totally Zenned

Join Date:
Apr 2008
Location:
Flint, Michigan
Posts:
684
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

:clap:
Thank you!
Kim

19 Apr 2009, 10:37 PM
#16
yaseent avatar

yaseent

Zen Follower

Join Date:
Mar 2009
Posts:
169
Plugin Contributions:
1

Re: how to keep categories unfolded on sidebox?

sotlordrahl:

This is how I hacked up the zen-cart code to have the ability to unfold ANY or ALL categories to display sub-cats on all pages, not just the index page:

open 'includes/classes/category_tree.php'

  1. change line 137

change

if (zen_not_null($cPath)) {

TO =>

if (zen_not_null($cPath) or 1) {


  1. insert code in lines 141-145

ORIGINAL

reset($cPath_array);

while (list($key, $value) = each($cPath_array)) {


insert =>

$cPath_array = array(#,#);

in between the reset and while commands.

equals the category ID you wish to be unfolded... you can have it only unfold one, or all... all would be #,#,#,#,# and so on until you have all the ID's inside the parenthesis.

END RESULT

reset($cPath_array);

$cPath_array = array(1,2,5,7);

while (list($key, $value) = each($cPath_array)) {


hope this helps some people, my buddy and I spent 2 hours trying to figure this one out. tried to add some hyphens in here for reading pleasure and such... do not insert the page breaks I made. ENJOY!!!

Any questions let me know, this is what worked for me.

Thanks man this works great except for one problem. I used it to expand the first category on my page, and at the moment my page has 2 categories each with sub-categories. So Cat1 stays permanantly expanded on the entire website, but when a person clicks on Cat2, it loads the page, but in the categories sidebox, Cat 2 does not expand. Is there any way to sort this out?

24 May 2009, 2:32 PM
#17
eliza_bee avatar

eliza_bee

New Zenner

Join Date:
Mar 2009
Posts:
10
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

i have installed the expanded category list, and can't see my products listed yet, not sure if this is the hack for me, as i don't have subcategories, and help appreciated.... i can't find a direct support thread for the expanded category list....:(

26 May 2009, 9:35 PM
#18
anap avatar

anap

New Zenner

Join Date:
May 2009
Location:
The West Coast
Posts:
25
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

Thank you, I struggled for 2 hours trying to figure out Simple Category Tree, gave up and installed this in 5 minutes as described, except the different line numbers for v1.3.8.

I had to change some of my a hover CSS as that didn't carry over well.

26 May 2009, 11:12 PM
#19
anap avatar

anap

New Zenner

Join Date:
May 2009
Location:
The West Coast
Posts:
25
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

Help! I can not set a style for the selected product after this hack.

Previously, I just added this line to the CSS to get the currently selected product highlighted with a background color on the categories sidebar:

#categoriesContent a.category-products SPAN.category-subs-selected {background-color: #669900;}

After the change, the site no longer uses the SPAN class, so there is no way for it to know which product is selected. What do I need to add to get that SPAN back in there? (v1.3.8) :wacko:

31 May 2009, 9:15 PM
#20
anap avatar

anap

New Zenner

Join Date:
May 2009
Location:
The West Coast
Posts:
25
Plugin Contributions:
0

Re: how to keep categories unfolded on sidebox?

Anyone else having problems with breadcrumbs after installing? All top level categories with a sort number higher than the current category are being displayed. :frusty:

i.e. instead of:
Home > Sweaters > Women's Sweaters

I am now getting:
Home > Belts > Tshirts -> Shorts > Sweaters > Women's Sweaters