Need help customizing category listing
OK... I need some help from the pros here... I am trying to do a customization for the category listing and just cant figure it out.
What I would like is when you click on a category, that you have the subcategory listing below the catagory that was clicked. I know that you can nest sections, but I can't figure out the proper way to do it. The closest that I have gotten is: Code:
{* $Id: categories.tpl,v 1.14 2002/09/10 12:58:26 zorg Exp $ *} This is close but not right. It list the first category only once, then list the main categories again as su categories. Then when you click on a category, it DOES list the sub categories inder the category clicked, but it does not list the remaining categories. If I change it to: Code:
{* $Id: categories.tpl,v 1.14 2002/09/10 12:58:26 zorg Exp $ *} Am I making any sense at all? |
Cascading Category/SubCategory Listings
Unfortunately, I have planned on doing this for a customer, but have not worked through it yet. But, I'll take a stab at this one...
If you are at the top level of the category tree, the subcategories are the same as the top-level categories, and that is why the first piece of code shows the main categories where you are expecting to see subs. The reason they aren't repeated is likely because you are using the same counter (cat_num) for both section loops. When it finishes the second section loop, the counter is left at the end and is falling out of the both the nested and outer loop. In the second piece of code your two loops are exclusive of one another, meaning that the first loop completes {/section} prior to starting the second loop. At the top level, I would expect it to run the whole category listing twice? Sorry, this has been more diagnostic of your code and not helping yet. The first code snippet looks the closest. You need to give each counter variable a different name and add a test to see if the category is the same as the category that was selected prior to listing the subcategories. Otherwise, you will not know where to cascade the subcategory listing. I can work up an example next week if you still are stuck. Hope this helps! |
I am trying to get this same feature. I found a site that utilizes it on a different platform. oscommerce open source storefront. The store is carnutz.cc. I am not a programmer by any means, but would love to pickup this code.
Thanks |
SOLUTION - Category Listing w/nested subcategories
Much easier than I thought. TelaFirma was _really_ close, just added a simple check for match of $cat. This was made to the 3.2.1 customer/categories.tpl file... I didn't build a third option for root_categories, I just used the "N" option.
Quote:
|
I am using version 2.4. Was able to get this to work, somewhat. Few issues, not sure if you guys are experiencing with a newer version.
1) Empty categories (no products) are showing up. 2) Once I click on the subcategory, they go away only displaying the top categories. Needs to show the second level sub categories. Please let me know if you are not having these problems. If not, I will look to upgrading. Thanks |
Hmmm
Jeff,
I just checked on this and you are right, once you click on the subcategory, the category list reverts back to the top level categories only instead of staying with the subcategory listing. Not a big surprise considering it reparses the category listings using the new "cat" that you just clicked on and it doesn't have any subcategories to the sub-category you just clicked on. Let me think about that and look at the code tomorrow. What about multi-level sub-categories? The "hack" that I sent out will only work for one level of sub-category. Do you have multiple levels of sub-categories? On the issue of empty categories being displayed, the existing system already did that. If you want to shut off a category that doesn't have any products, you can "disable" that category in the admin interface. |
I do have multi levels of categories, but I only want to display the main category and the first sub-category on the left bar.
My store will be setup offering different categories and different items under that. For ease of naviagtion, once a customer picks the initial category, which they will most likely remain within, they can then navigate within that category very easily. I will utilize the disable function on empty categories. Thank you! |
Yes, this is VERY close... I think that if we could just keep the single sub-cateogry list displayed, that would be enough to be useful...
|
Cascading Category Names
Sorry for the delay. Looks like I need to make a small change to categories.php. I'm booked solid today, but will get a change out tomorrow (Friday US time) to do this.
|
No rush... no rush at all....
|
Finished! Indented Sub-categories.
OK. I have this working the "simple" way, with only one level of "indentation" in the category tree. The elegant way would have been to build a multi-dimensional array, but figured there was already enough overhead in categories.php, and there isn't really enough room to effectively build a 3+ level navigation model without losing valuable product space.
I had to change: /xcart/include/categories.php /xcart/skin1/customer/categories.tpl /xcart/skin1/location.tpl /xcart/skin1/customer/main/products.tpl I made the changes for 3.2.1, but see that categories.php changed for 3.2.2. I'll post the 3.2.1 changes for now and post the 3.2.2 changes if anyone wants them. See the next message for the specific file changes... |
3.2.1 category customization
Here are the changes described in previous posting:
I'll PREFIX the changes with ##BEGIN and end with ##END /xcart/include/categories.php Code:
# /xcart/skin1/customer/categories.tpl Code:
{* $Id: categories.tpl,v 1.14 2002/09/10 12:58:26 zorg Exp $ *} /xcart/skin1/customer/main/products.tpl Code:
{* $Id: products.tpl,v 1.16 2002/09/25 10:12:05 zorg Exp $ *} /xcart/skin1/location.tpl Code:
{* $Id: location.tpl,v 1.6 2002/09/05 12:43:21 zorg Exp $ *} Obviously no warranty on the code, it works for me under 3.2.1. Let me know if you have any issues making this work! |
I would appreciate the 3.2.2 changes that you were talking about if it is not too much trouble. I already made the upgrade (a lot of which I had to do manually due to existing modifications).
|
Anyone have this working so I can see what it looks like?
|
Working on a site...
I just pulled that demo site down today. I'm working through a rebuild to a different version for an older customer. I'll put my demo site to 3.2.2 and add this code to it this weekend and send a pointer. Bad timing :-)
|
Any word on the 3.2.2 update?
Thanks |
same here!
any word on the latest version listing
|
Finally reworked for 3.3.1
I finally had a free moment to make the minor changes for 3.3.1. Please remember that this will only show the category and one level of sub-category. A completely different approach would need to be taken to cascade to more levels.
Here are the 3.3.1 changes required: I preserved the "root categories" function from the General Settings, so you will need to turn it to "N" for the code below to work. /xcart/include/categories.php Code:
<? /xcart/skin1/customer/categories.tpl Code:
{* $Id: categories.tpl,v 1.16 2002/10/21 07:06:43 zorg Exp $ *} /xcart/skin1/customer/main/subcategories.tpl Code:
{* $Id: subcategories.tpl,v 1.29 2002/11/26 14:55:13 alfiya Exp $ *} /xcart/skin1/customer/main/products.tpl Code:
{* $Id: products.tpl,v 1.21 2002/11/19 12:57:48 alfiya Exp $ *} /xcart/skin1/location.tpl Code:
{* $Id: location.tpl,v 1.7 2002/10/17 13:54:56 zorg Exp $ *} /xcart/customer/main/navigation.tpl Code:
{* $Id: navigation.tpl,v 1.6 2002/10/22 10:27:05 olga Exp $ *} I think that is it. If you just pull the changed lines you can use the same code changes for 3.2.1 and 3.2.2. Just be sure and only use the changed lines and get them inserted into the comparable positions. Enjoy. -Derrick |
Do you think this would work with any other versions like 3.2?
|
I haven't looked, but seeing that 3.2.1 and 3.2.2 are just "dot" releases, meaning mostly bug fixes, etc. and the fact that it was pretty easy to see the changes made for 3.3.1, it should be very close.
I would begin by looking in categories.php for the comparison. -Derrick |
do you mind if we can see an example of what you made...I have no doubt of your abilities but i just want to know if this is really what i want on my site...thanks
|
Sure. I originally did this for a prospect under 3.2.1, but they went away. Since so many people seemed interested, I went ahead and setup a generic test 3.3.1 site and made only this change. I will be pulling this site down to build my next project, but will leave it up for a couple days max.
http://www.freerangeminds.com/shop/ Just the generic 3.3.1 demo products. Remember that this only displays the category and subcategory (1 level). Any deeper and it will only leave the subcategory displayed. -Derrick |
wow!!!! it looks so cool.. :lol: .i'm going to implement it on my 3.2 site...i'll let you know if it worked. :P
|
well i tried but i couldn't get it to work?!?
any ideas...i see that the 'topcat' is working (as you can see by the links) but the menu is not working as yours....any ideas... |
Hmmm. Did you go into admin mode, General Settings and "uncheck" the show root categories?
|
hahahahahaha....no i didn't sorry...working hard at copying and pasting your hack i forgot to do the last thing...it works...thanks...now i have to change all the css to fit the site.
|
it looks tight...thanks a lot...is there anything i can share with you? I would feel better to trade hacks...even though there aren't much i hacked...but maybe i could help with something on your site?
well don't hesitate to ask me for help....is what i'm basically saying... |
I'm glad it works for you. I think I am all set on the customer sites I have worked up. Thanks for the offer.
|
oh i just realized that you forgot to mention
/customer/main/navigation.tpl You will notice the problem here(http://www.freerangeminds.com/shop/customer/home.php?cat=105&topcat=103) look at the results page. when you click on the next page you'll notice the menu collapses... I edit it but since my site is completely reconfigured I'm afraid to add my codes here and get some beginner confused. Derrick, mind adding the original code and corresponding edits. |
Good catch. I am so use to the cart being setup for longer listings, I completely forgot. I updated the original posting to include the navigation.tpl with the mods.
-Derrick |
I've been working on something similar to this, instead of using HTML I'm building XML that flash is parsing and building a category tree thats browsable without making the clients browser referesh on every click, so far I don't have a demo up, as the client I was doing it for, his hosting provider had an HD crash and lost all my work, so I'll be rewriting this, and hopefully will have a preview. This could be achieved also with some DHTML, it would really be a matter of spacing the menu out, as I've left the basic cat on the left and added my flash category's to the middle area above featured products. This is sorta similar to how macromedia.com's side nav bar works.
None, the less, this is a great HTML mod for the categories, kudos derrick! :wink: |
I have added this to my x-cart test installation, and on the customer end it works perfectly... However, there is a problem in the admin panel when trying to add or modify categories. I get the following error message:
Warning: Cannot add header information - headers already sent by (output started at /estore/include/categories.php:160) in /estore/admin/process_category.php on line 56 (or 65) If I restore the original /xcart/include/categories.php file, then this error goes away, but then the effect no longer works when I am inside a sub-category. Any help please? :) |
Ignore my previous post - I re-uploaded the categories.php file, and it works :oops:
Thanks for a great addition :) |
When installed and items are added to the cart, the sub-category listing closes. To continue shopping, one must re-select the main category to re-list the 1st layer of sub-categories. Any idea how to have the first layer remain open?
Thanks |
works fine on 3.4.1
just install on 3.4.1 and it seems to work until you get to the product detail...
|
Trying to get this category display in the "cart" area. Any ideas? I have had several complaints from customers on being able to continue shopping and this should help.
Added the continue shopping "back" feature, but the category drill down does not return? Thanks |
I have been trying this code and derivatives of, yet I am unable to get the code to even recognize the $topcat variable.... is there a place where the smarty templates have to grab the variable via PHP before I can use it in the SMARTY templates? I see the variable being passed inthe url... but i can't use it...
any help would be greatly appreciated... www.budogear.com/customer only the last category (missing gif) has sub categories... once you click on that, the sub menus appear, but after you click on the submenu,(in the left column) they no longer appear... |
Any idea if this will work in 3.4.8?
|
X-Cart 3.4.7
I just tried this in X-Cart 3.4.7 and it makes the categories blank. Anybody have a clue? Can anybody make this work for this version number?
|
Is there anybody else doing this that can also show more than one sub-category.
|
All times are GMT -8. The time now is 04:07 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.