How do I display all subcategories along with all products
How do I display all subcategories along with all products under each subcategory on one page, here is what I want to do:
1 root category, has 2 subcategories, when customer clicks on root category, the subcategories.tpl displays 2 lines listed 2 subcategories, which is pretty ugly, I want it to dispaly like the following: subcategory1 product1 under subcategory1 product2 under subcategory1 product3 under subcategory1 .... subcategory2 product1 under subcategory2 product2 under subcategory2 ..... Thanks in advance if you can point me into a right direction |
TTT. I am looking for the same exact thing. Did anyone contact you prvately by chance with a aolution? Or were you able to find something in another threads that solved this for you? Thanks!
Brian |
:: EDIT ::
Okay here's what I did and so far it seems to work: The $products array gets defined in a code snippet at the bottom of $xcart_dir/products.php. I moved that code snippet into a new file $xcart_dir/products_by_catid.php and modified products.php to include the new file. Now I have the freedom to load a $products array any time I want. I simply set $cat then include products_by_catid.php. After I verified that this small change worked (i.e. hit reload and page still there), I then modified products.php to cycle through the $subcategories array and, for each subcategory, grab the products list and store it in a "products" field. What would make this mod really nice would be a simple way to enable/disable it from the admin console. Any Ideas? Also, the code snippet that I added to products.php could just as easily be placed in $xcart_dir/home.php instead, which may actually be a more appropriate place for it. Feeback appreciated. Thanx -D PS: Oh, and it would be nice to have another mod that would add the subcats for the subcats :) I might try that one later. --- Here's a small test snippet and the file changes for the mod: Test Snippet To Try In: $xcart_dir/skin1/customer/main/subcategories.tpl Code:
{if $subcategories} Create New File: $xcart_dir/products_by_catid.php Code:
<?php Modify File: $xcart_dir/products.php Code:
<?php === Original Post === I could really use a response to this if anyone is out there? It looks like "products.php" finds the product list via a specialized search. I was thinking we could do a similar thing within the loop that cycles through the sub-cats. I was also thinking of trying to modify home.php and/or categories.php and/or products.php to create "subcat_products[subCatId]" (and possibly subcat_subcats[]) My concern with these is the extra function calls or includes changing variables that aren't needed for this mod but might be needed by other pages. Ideas? |
Re: How do I display all subcategories along with all products
I needed to add
Code:
$products = ""; Code:
$smarty->assign("subcategories",$subcategories); Here's why: If the category has no products but has multiple subcategories, and if the last category of those subcategories has products, the page would display these products twice. Once within the sub category and once underneath the category. |
Re: How do I display all subcategories along with all products
Do you guys have a sample URL I could take a look at to see what this would look like?
|
Display SubCategory titles with products
I have searched through the forum and could not find anyone who has been able to implement this:
SubCategory Title ------------------------------------------- product1 product2 product3 product4 SubCategory Title2 ------------------------------------------- product1 product2 product3 product4 Right now, it only shows products in the root category with all the SubCategory Titles above. |
Re: Display SubCategory titles with products
Do you mean on the crumb trail ?
|
Re: How do I display all subcategories along with all products
Here's a store that utilizes this custom mod: View Example Live Store
The store owner hasn't added many products yet but you should still be able to get a good idea of how it looks. |
Re: How do I display all subcategories along with all products
Do you have the mod instructions for installation? I am using 4.1.8 and it does not apear to work for me with the instructions above.
|
Re: Display SubCategory titles with products
No, on the actual page.
I need it to appear like this sample: http://www.jackmansfabrics.com/Bridal-Fabrics-p-1-c-294.html |
Re: How do I display all subcategories along with all products
That store that I linked to is 4.1.8 and I used the instructions that were listed in a post above mine with the one modification that I mentioned in one of my other posts.
|
Re: How do I display all subcategories along with all products
I have tried this one and it works well except for one thing, it is only showing up the products of the last category not in other categories with products on the same level.
Any ideas? Thanks. |
Re: Display SubCategory titles with products
I just created something similar to what you need from an old posting a couple of days ago.
I just modified it a little to make it work on v4.1.8 First of all, kudos to the creator and all those that contributed to the original mod. Start by opening up the xcart/include/categories.php file. And find these lines of code: (it's at the bottom) Code:
Code:
Now, replace your skin1/customer/categories.tpl with this modified categories.tpl Code:
Code:
And that's it. - MoonDog - |
Re: Display SubCategory titles with products
I followed the steps you gave, MoonDog, and I don't see a change: http://sentimentalist.net/store/greeting-cards-c-1.html
I even ran cleanup.php to make sure my temp files were cleaned out. Did I do something wrong? |
Re: Display SubCategory titles with products
Hi MoonDog,
Thanks so much for this post. I am also having the same problem. I followed all the instructions, but still cant get the products to display in the menu. It now displays the subcategories. |
Re: Display SubCategory titles with products
1 Attachment(s)
RobinBraves,
Unfortunately you won't be able to use this code on your site :( . I went to your site (great site by the way) and noticed that you are using javascript code for your current menu. Since you have a customized menu you will have to remove and modify your code in order for this to work. By the way, on your site, the last three items of your custom menu doesn't work in Internet Explorer 6. You can't see any of the text unless you hover over them. It works OK in Firefox though. andyweb, I've copied the code from this post and followed my exact instructions to see if there was a typo or bad code. I re-installed it and tested it and it still works like a charm. I've attached a thumbnail so you can see what it is suppose to look like. You might try re-doing the installation again in case you made a previous mistake. - MoonDog - |
Re: Display SubCategory titles with products
Not sure if this is what I will need. Does this make the actual page in the middle show the subcategory titles with all their products listed below?
Example: ------------------------------------------------------- Celebration ------------------------------------------------------- product1 product2 product3 product4 product5 ------------------------------------------------------ Gratitude ------------------------------------------------------ product1 product2 product3 ------------------------------------------------------ Seasonal ------------------------------------------------------ product1 product2 product3 product4 product5 product6 product7 |
Re: Display SubCategory titles with products
RobinRaves,
Quote:
I did post some code a while back that deals with sub-categories and sub-sub-categories in the middle of the page, but it used graphics and text. I'm not sure if this is what you need, but click here to go there. I've placed two thumbnail images on the bottom of that post so you can see if that is what you need. - MoonDog - |
Re: Display SubCategory titles with products
No problem, MoonDog. I really do appreciate your help. I took a look at that other forum and it is not what I need.
What I need is seen here: http://www.jackmansfabrics.com/Bridal-Fabrics-p-1-c-294.html This page shows a SubCategory Heading with the products below and then ANOTHER SubCategory Heading below that and its products below and so forth. By default, x-cart just shows the subcategories (with or without images) but not the products. You actually have to click on the subcategory to see the products of just that subcategory. I need for my customer to see all the subcategory headings with the corresponding products below each. I hope that makes sense. I saw 1 thread about this, but it was not made for 4.1.8 or newer. I'm kinda bummed out. Good news is... I think I am going to use this mod anyway because the menu I have is "jumpy" and I'm not a huge fan. |
Re: How do I display all subcategories along with all products
Quote:
Okay, I followed the instructions exactly and also made the update that you posted. Here is what my page looks like: http://sentimentalist.net/store/greeting-cards-c-1.html Any suggestions? What could I be doing wrong/ |
Re: How do I display all subcategories along with all products
1 Attachment(s)
RobinBraves,
Looks like you've done everything correct. All you need to do now is to convert the sample code in subcategories.tpl to something that will read your data and place it formated on the page. If you need some code to get you going I've gathered some code from various different threads and altered the subcategories.tpl file to show the output in icons and text. It is also hyperlinked so that you can click on the icon and the text. I've attached a thumbnail so you can see what it looks like. First, add this code to the end of your skin1.css file: Code:
Code:
If you need to change it to two column then change these 2 lines of code in subcategories.tpl: Code:
And for 4 columns you need to replace them to 4 And also at these 2 lines of code: Code:
{if $tmp is not div by 3} You also need to change the percentage code you placed in your skin1/skin1.css file. Example: for 2 columns it's 50% Code:
Code:
Unfortunately I've been so busy, I didn't have much time to test it out completely, but it's a start to get you going. You might have to change the table code or the css code to what you need. I also didn't work on the sort order (it's ordered alphabetically), it's different than the sort order on the menu (see the thumbnail). You can change the position order in the categories section of the admin side. Anyway, hope this will get you going. - MoonDog - |
Re: How do I display all subcategories along with all products
Where exactly in the subcategories.tpl does the following code go. I've tried it in a few different places an end up getting a whole load of offset text which outlines the contents of the subcategories but no actual products.
Thanks. {if $subcategories} <ul> {foreach from=$subcategories item=subcat} [*]{$subcat.category|escape} <ul> {foreach from=$subcat.products item=subproduct} {if $subproduct} [*]{$subproduct.product|escape} {/if} {/foreach} [/list] {/foreach} [/list]{/if} |
Re: How do I display all subcategories along with all products
You are a genius! Sorry for taking so long to get back. This worked and I will need to make some css and table adjustments, but that will be easy to do.
I really appreciate this.. I can actually feel stress relieving off of me. |
Re: How do I display all subcategories along with all products
RobinBraves,
Glad to see you got it working and not as stressed anymore. :-) designtheweb, Quote:
Just follow the instructions I posted previously without this test code and you will see the products displayed instead of text. - MoonDog - |
Re: How do I display all subcategories along with all products
This code seems to change the layout of the individual products. is there a way to keep the individual products layout but have the products under the subcategories?
|
Re: Display SubCategory titles with products
this is EXACTLY what I wanted. Thank you for sharing. Great works...hope I can get the subcategories show as subcategories. Right now, they all show as categories...can't tell which is subcategories. Had to play with it to get it work... ;-(
|
Re: Display SubCategory titles with products
Works like a charm, thank you for this.
|
Re: Display SubCategory titles with products
Yep, exactly what I wanted. Thanks!!
Scotty |
Re: Display SubCategory titles with products
Just out of curiosity... I've looked all over the forums but can't find what I'm looking for.....
Is there a way to have only the main cats show and expand down to show the subs only in that cat once it's clicked? |
Re: Display SubCategory titles with products
Fancy Categories does that but not expand, only popup. Use x-cart demo and you will see Fancy Categories in action.
|
Re: Display SubCategory titles with products
Don't mean to bump this up but thanks very much moondog, i really needed this :)
|
Re: Display SubCategory titles with products
Quote:
Did you ever figure out how to do this...I am looking to do the same. |
Displaying products in subcategory on category page
I having trouble figuring out how to display all products in all the subcategories on the category page like this:
subcat name1 product 1 product 2 subcat name2 product 1 product 2 etc... I would only like to do this on certain categories (I can use an if statement and include a different template) or display like above only for categories that have subcategories. Any help would be greatly appreciated. Thanks |
Re: Displaying products in subcategory on category page
1. home.php
Code:
define('OFFERS_DONT_SHOW_NEW',1); 2. skin1/customer/main/subcategories.tpl Code:
{* $Id: subcategories.tpl,v 1.55.2.4 2008/07/15 12:07:40 ferz Exp $ *} |
Re: Displaying products in subcategory on category page
Thanks so much for the mod Victor! Worked like a charm!!!
I added a link to the products display in subcategories.tpl: Change this: <td colspan="3">{$sprods.product}</td> to this: <td colspan="3"><a href="product.php?productid={$sprods.productid}">{ $sprods.product}</a></td> Thanks again Victor. You Rock!!! |
Re: Displaying products in subcategory on category page
This looks like a great mod, but in 4.2.1, subcategories.tpl looks so different than the version above, that I didn't even attempt this mod. Anyone know how to adjust this to 4.2.1?
|
Re: Displaying products in subcategory on category page
For 4.2.1 (home.php code is the same with one from the post#2)
skin1/customer/main/subcategories_t.tpl: Code:
{* skin1/customer/main/subcategories_list.tpl: Code:
{* this is a basic way to insert products. You may improve layout according to your requirements. |
Re: How do I display all subcategories along with all products
Quote:
Yeah, I'm looking for a way to run the subcategory links along with the existing product list in alphabetical order, instead of the stock subcategory's listing on top, followed by the product list beneath. Stock x-cart layout, subcats (no icon/description), products include icon/description: a subcat1 b subcat2 c subcat3 _______________ a product1 b product2 c product3 Desired Mod should include product/subcat name + description and icon and sort alphabetically: a product1 b product2 c subcat1 d product3 e subcat2 f subcat3 |
Re: How do I display all subcategories along with all products
This mod is excatly what i'm looking for but I want to keep my existing product.tpl format, not have it reoganized.
ANy advice? |
Re: How do I display all subcategories along with all products
Quote:
is this going to work in 4.2? Thanks |
All times are GMT -8. The time now is 11:18 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.