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

How do I display all subcategories along with all products

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #21  
Old 11-03-2007, 02:27 PM
 
MoonDog MoonDog is offline
 

Advanced Member
  
Join Date: Aug 2007
Posts: 93
 

Default Re: How do I display all subcategories along with all products

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:
.ColumnTitles { TEXT-ALIGN: center; WIDTH: 33%; PADDING-LEFT: 5px; }
Then replace the code from <table> to </table> in the skin1/customer/main/subcategories.tpl file with the code below:
Code:
<table cellspacing="5" width="100%" border="2"> {foreach from=$subcategories item=subcat} <tr> <td class="ColumnTitles" valign="top"><a title="{$subcat.description}" <a href="home.php?cat={ $subcat.categoryid }"><img src="{if $subcat.icon_url}{$subcat.icon_url}{else}{$xcart_web_dir}/default_image.gif{/if}" alt="" /><br> <font class="ItemsList">{ $subcat.category|escape }</font></a> </td></tr> {foreach from=$subcat.products item=subproduct} {if $tmp is div by 3} <tr><td colspan="3"></td></tr> <tr valign="top"> {/if} { if $tmp and $first_subproduct ne "Y" } {assign var="tmp" value=0} {assign var="first_subproduct" value="Y"} {/if} {if subproduct} <td class="ColumnTitles" valign="top"><a title="{$subproduct.description}" <a href="product.php?productid={$subproduct.productid}&amp;cat={ $subproduct.productid }&amp;cat={$cat}&amp;page={$navigation_page}"><img src="{if $subproduct.tmbn_url}{$subproduct.tmbn_url}{else}{$xcart_web_dir}/default_image.gif{/if}" alt="" /><br> {$subproduct.product|escape} {/if} <br> {assign var="tmp" value=$tmp+1} {/foreach} {if $tmp is not div by 3} {assign var="tmp" value=3} {/if} {/foreach} </tr> </td> </table>
The above code produces three columns.
If you need to change it to two column then change these 2 lines of code in subcategories.tpl:
Code:
{if $tmp is div by 3} <tr><td colspan="3"></td></tr>
For two columns you need to replace both number 3's to 2
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} {assign var="tmp" value=3} {/if}

You also need to change the percentage code you placed in your skin1/skin1.css file.

Example: for 2 columns it's 50%
Code:
.ColumnTitles { TEXT-ALIGN: center; WIDTH: 50%; PADDING-LEFT: 5px; }
Example: for 4 columns it's 25%
Code:
.ColumnTitles { TEXT-ALIGN: center; WIDTH: 25%; PADDING-LEFT: 5px; }

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 -
Attached Thumbnails
Click image for larger version

Name:	SubCategories.gif
Views:	315
Size:	32.1 KB
ID:	613  
__________________
X-CART Gold v4.1.8
Reply With Quote
  #22  
Old 11-07-2007, 11:36 AM
  designtheweb's Avatar 
designtheweb designtheweb is offline
 

Senior Member
  
Join Date: Mar 2005
Location: Sydney Australia
Posts: 132
 

Default 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}
__________________
"The more you know - the less you pay"

Various websites using

4.66 Pro & 5
Reply With Quote
  #23  
Old 11-07-2007, 03:39 PM
 
RobinBraves RobinBraves is offline
 

Advanced Member
  
Join Date: Oct 2005
Location: FL
Posts: 98
 

Default 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.
__________________
Version 4.1.11
Reply With Quote
  #24  
Old 11-09-2007, 09:43 PM
 
MoonDog MoonDog is offline
 

Advanced Member
  
Join Date: Aug 2007
Posts: 93
 

Default 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:

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.
The test code that you are using in the subcategories file is just logic. All that you would be getting is like you described; offset text which outlines the contents of the subcategories but no actual products.
Just follow the instructions I posted previously without this test code and you will see the products displayed instead of text.

- MoonDog -
__________________
X-CART Gold v4.1.8
Reply With Quote
  #25  
Old 02-12-2008, 07:20 PM
 
Chrisb Chrisb is offline
 

Member
  
Join Date: Jan 2008
Posts: 25
 

Default 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?
__________________
www.easycoffee.com.au
Version 4.1.9
Reply With Quote
  #26  
Old 03-24-2008, 07:58 PM
  MythNReality's Avatar 
MythNReality MythNReality is offline
 

X-Adept
  
Join Date: Mar 2005
Location: S. Cali
Posts: 403
 

Default 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... ;-(
__________________
_____________
Capture Your Mini-Me Look!

- X-CART Gold (Current Version) V4.6
- Reboot
- CDSEO
Reply With Quote
  #27  
Old 05-09-2008, 01:45 AM
 
bitstream bitstream is offline
 

Newbie
  
Join Date: Apr 2008
Posts: 7
 

Default Re: Display SubCategory titles with products

Works like a charm, thank you for this.
__________________
X-cart Pro Version 4.1.9
Reply With Quote
  #28  
Old 07-03-2008, 02:26 PM
 
Scotty85 Scotty85 is offline
 

Advanced Member
  
Join Date: Mar 2008
Posts: 94
 

Default Re: Display SubCategory titles with products

Yep, exactly what I wanted. Thanks!!

Scotty
__________________
Xcart Version 4.1.9
Upgraded to 4.1.10 (clean install with mods added back)
Reply With Quote
  #29  
Old 07-03-2008, 08:37 PM
 
Scotty85 Scotty85 is offline
 

Advanced Member
  
Join Date: Mar 2008
Posts: 94
 

Default 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?
__________________
Xcart Version 4.1.9
Upgraded to 4.1.10 (clean install with mods added back)
Reply With Quote
  #30  
Old 07-03-2008, 11:05 PM
 
bitstream bitstream is offline
 

Newbie
  
Join Date: Apr 2008
Posts: 7
 

Default 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.
__________________
X-cart Pro Version 4.1.9
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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:37 AM.

   

 
X-Cart forums © 2001-2020