Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Adding category title to products listing

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-13-2014, 05:59 AM
 
jlat jlat is offline
 

Member
  
Join Date: Jan 2014
Posts: 17
 

Default 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.
__________________
xcart Gold Plus 4.6.3
Reply With Quote
  #2  
Old 04-13-2014, 09:14 AM
 
jlat jlat is offline
 

Member
  
Join Date: Jan 2014
Posts: 17
 

Default 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.
__________________
xcart Gold Plus 4.6.3
Reply With Quote
  #3  
Old 04-13-2014, 09:17 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default 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?
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #4  
Old 04-13-2014, 11:57 AM
 
jlat jlat is offline
 

Member
  
Join Date: Jan 2014
Posts: 17
 

Default 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.
__________________
xcart Gold Plus 4.6.3
Reply With Quote
  #5  
Old 04-14-2014, 01:51 AM
 
jlat jlat is offline
 

Member
  
Join Date: Jan 2014
Posts: 17
 

Default Re: Adding category title to products listing

I've got this figured out now. X-cart doesn't make things easy!
__________________
xcart Gold Plus 4.6.3
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:17 PM.

   

 
X-Cart forums © 2001-2020