Zen Cart Logo
Forums / General Questions / Show subcats + products

Show subcats + products

Views: 589

Results 1 to 7 of 7
17 Feb 2016, 8:08 AM
#1
ghoul avatar

ghoul

New Zenner

Join Date:
Feb 2016
Posts:
11
Plugin Contributions:
0

Show subcats + products

Hi everyone. I have a little problem with products in subcategories. I will try to explain you.
For example I have main category with subcategories.
Main category

That what I want is to show subcategories tabs above and products from this subcategories below.
I think that part of code is the key:

if(!empty($sub_cats))
$categories_products_query = "SELECT count() AS total
FROM " . TABLE_PRODUCTS_TO_CATEGORIES . "
WHERE categories_id IN ($sub_cats)";
else
// eof all_sub_cats_products
$categories_products_query = "SELECT count(
) AS total
FROM " . TABLE_PRODUCTS_TO_CATEGORIES . "
WHERE categories_id = :categoriesID";

This code is in - includes/modules/pages/index/header_php. (line from 22 to 30)

I use ZC 1.5.0
Thanks!

17 Feb 2016, 9:59 PM
#2
ghoul avatar

ghoul

New Zenner

Join Date:
Feb 2016
Posts:
11
Plugin Contributions:
0

Re: Show subcats + products

Can anybody help me ? Pls? I want to show subcats tabs and products at the same time when i click on the main category. What must I change at the code to shows that what I want? Pls Help me?

17 Feb 2016, 10:35 PM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Show subcats + products

This is a little more involved than just saying "do this". There are templates that have incorporated such action, and they may be a good starting point. There are other things to consider on the presentation side such as are there going to be fly out menus, which way, what if they are really long, etc...

Primarily what is needed is to track the structure of the categories from the "root", then as a category is presented to identify if there are product in that category and what sub-category(ies) exist off of that. Continue until at the end of the last category and/or set of products.... If your setup will only have product at the end of a category branch, then the code is a little simpler, but you'll be limiting what can happen/be displayed.

The code snippet identified above merely addresses the number of things to address, not necessarily how that is then used/broken down. The header file will provide data applicable for use in the template file(s)/module(s) invoked to present the data. Just remember that unless the tree gets trimmed on various selections/navigation that that data will be sent with each page load and tied to an efficiencies of navigating the site...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

18 Feb 2016, 8:07 PM
#4
ghoul avatar

ghoul

New Zenner

Join Date:
Feb 2016
Posts:
11
Plugin Contributions:
0

Re: Show subcats + products

So... you telling me that what i want is too difficult to make?

18 Feb 2016, 8:52 PM
#5
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Show subcats + products

GhouL:

So... you telling me that what i want is too difficult to make?

Not too difficult to make. Maybe too difficult for me to type/copy all of the code using my cell phone. Would take longer to do from scratch when there are already templates and potentially partial templates that do this. Using the code changes of such a template, the applicable parts could be used/applied to your site. Yes, I know the next thing is to know where it is already factored. Otherwise I believe I provided the logic above that could be used to obtain the result requested. My only thing was an offering to consider the results, full implementation, and effect of implementing.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

20 Feb 2016, 3:15 PM
#6
ghoul avatar

ghoul

New Zenner

Join Date:
Feb 2016
Posts:
11
Plugin Contributions:
0

Re: Show subcats + products

Ok, thanks "mc12345678"! I understand it`s difficult to make with cell phone, but can someone else who has free time to help me ?

25 Feb 2016, 7:22 PM
#7
ghoul avatar

ghoul

New Zenner

Join Date:
Feb 2016
Posts:
11
Plugin Contributions:
0

Re: Show subcats + products

So... can anybody help me ? Pls ?