X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Adding category title to products listing (https://forum.x-cart.com/showthread.php?t=69020)

jlat 04-13-2014 05:59 AM

Adding category title to products listing
 
Hi,

I was wondering there is a simple solution to this problem before I get coding.

At the moment when clicking a category it shows a list of products within the category, also including products in any sub categories. The products are all in one long list, I want to show category titles for each sub category.

At the moment it's like this:

product 1
product 2
product 3
product 4
product 5
product 6
product 7
product 8
product 9

I want it to display like this:

product 1
product 2
product 3

Sub-Category Title
product 4
product 5
product 6
Sub-Category Title
product 7
product 8
product 9

I would have thought this was simple to do, but I don't think it is?

Thanks for any advice.

jlat 04-13-2014 09:14 AM

Re: Adding category title to products listing
 
I've realised that this isn't going to be simple. I think what I'll need to do is generate an array for each category and load each product into it that appears in the relevant category. Then I can loop through all categories and show all products that are in that category, and easily have the category title above.

totaltec 04-13-2014 09:17 AM

Re: Adding category title to products listing
 
Is this stock behavior? Can you provide a link to the example page? In my category pages (running 4.6.1) I don't have the subcategory products displayed. http://trainingpen.com/home.php?cat=5

Have you perhaps added the subcategory products into the main category as well as additional categories? Which is the main category for the subcategory's products, the sub, or the primary?

jlat 04-13-2014 11:57 AM

Re: Adding category title to products listing
 
No it's not standard, what I did was open /products.php and there is the following code near the bottom of the page:

Code:

$search_data['products'] = array(
    'categoryid'              => $cat,
    'search_in_subcategories' => 'N',
    'category_main'          => 'Y',
    'category_extra'          => 'Y',
    'forsale'                => 'Y',
    'use_cached_ids'          => TRUE,
);


I changed the 'search_in_subcategories' to Y and it now shows all products within a category, but as I've found out if a product is in multiple categories it doesn't show them all.

jlat 04-14-2014 01:51 AM

Re: Adding category title to products listing
 
I've got this figured out now. X-cart doesn't make things easy!


All times are GMT -8. The time now is 03:38 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.