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) {
-----------------------------------------------------------------------------------
2) 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.
Re: how to keep categories unfolded on sidebox
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
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.
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...
Re: how to keep categories unfolded on sidebox
Quote:
Originally Posted by
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;
Code:
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:
Re: how to keep categories unfolded on sidebox
Thank you so much. I spent like 6 hours trying to find this!!!:D
Re: how to keep categories unfolded on sidebox
Can you post a website we can view how it works?
Thanks,
Kim
:smile:
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
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