X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   2 Column Subcategory Display (https://forum.x-cart.com/showthread.php?t=1016)

amanda 12-21-2002 04:15 AM

2 Column Subcategory Display
 
Hi

Can someone tell me how to change the subcategories so they are listed in 2 columns without the product numbers??

Thanks
Amanda

Merry Christmas Everybody!

B00MER 03-25-2004 01:29 PM

Little late but here is the code for this in 3.5.x:

Code:

{* divide subcategories into 2 columns www.cart-lab.com written for 3.5.x *}
{ include file="location.tpl" }
{if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu ne "Y"}



{include file="modules/Bestsellers/bestsellers.tpl"}
{/if}



{ include file="customer/main/navigation.tpl" }
{if ($navigation_page eq "")||($navigation_page eq "1")}{$current_category.description|regex_replace:"/[\n]/":"
"}

{/if}
{capture name=dialog}
{assign var="tmp" value="0"}
{section name=cat_num loop=$subcategories}
{if $subcategories[cat_num].category}{assign var="tmp" value="1"}{/if}
{/section}

{section name=cat_num loop=$subcategories start=1}

{math equation="x/2" x=$smarty.section.cat_num.max assign="counter" }

{if %cat_num.first%}
{if $tmp} [img]{if $current_category.icon_url}{$current_category.icon_url}{else}{$xcart_web_dir}/icon.php?categoryid={$cat}{/if}[/img] {/if}
<table border=0 width="100%" cellspacing=5><tr>
{/if}

<td width="50%"><font class="ItemsList">{ $subcategories[cat_num].category_name|escape }</font>
</td>

{if %cat_num.index% is div by 2}</tr><tr>{/if}
{*
<td align=right nowrap><font class=Text>
{if $config.Appearance.count_products eq "Y"}
{if $subcategories[cat_num].product_count}
{ $subcategories[cat_num].product_count } {$lng.lbl_products}
{elseif $subcategories[cat_num].subcategory_count}
{ $subcategories[cat_num].subcategory_count } {$lng.lbl_categories|lower}
{/if}
{/if}
</font></td>
</tr>
*}
{ if %cat_num.last% }
</tr></table>
{/if}
{/section}

{if $tmp and $products ne "" }
<br clear=_all><hr size=1 noshade>
{/if}
{include file="customer/main/products.tpl" products=$products}
{if $products eq "" and $tmp eq "0"}
{$lng.txt_no_products_in_cat}
{/if}
{/capture}
{include file="dialog.tpl" title=$current_category.category_name|regex_replace:"/.*\//":"" content=$smarty.capture.dialog extra="width=100%"}
{if $products eq ""}
{if $f_products ne ""}



{include file="customer/main/featured.tpl"}
{/if}
{/if}
{ include file="customer/main/navigation.tpl" }


SMDStudios 04-08-2004 08:09 AM

This mod appears to drop the first subcat in the site. I've looked at the code for awhile can not figure it out.

B00MER 04-10-2004 08:09 AM

It may be because of the start=1 in the section loop.

Code:

{section name=cat_num loop=$subcategories start=1}
:?

SMDStudios 04-12-2004 11:44 AM

When I set start=0 it doesn't display the table correctly.

Link: http://www.shopgspot.com/shop/home.php?cat=248
FYI this is an adult site.

Quote:

Originally Posted by B00MER
It may be because of the start=1 in the section loop.

Code:

{section name=cat_num loop=$subcategories start=1}
:?


B00MER 04-15-2004 11:20 AM

Code:

{* first coloumn *}
<TABLE width="100%"><TR><TD valign="top" width="50%">

{section name=cat_num loop=$subcategories start=0 step=2}
{math equation="x/2" x=$smarty.section.cat_num.max assign="counter"}
{if %cat_num.first%}
{if $tmp} [img]{if $current_category.icon_url}{$current_category.icon_url}{else}{$xcart_web_dir}/icon.php?categoryid={$cat}{/if}[/img] {/if}
<table border=0 width="100%" cellspacing=5><tr>
{/if}
<td width="50%">{ $subcategories[cat_num].category_name|escape }
</td>
</tr><tr>
{ if %cat_num.last% }
</tr></table>
{/if}
{/section}

{* 2nd coloumn *}
</TD><TD valign="top" width="50%">

{section name=cat_num loop=$subcategories start=1 step=2}
{math equation="x/2" x=$smarty.section.cat_num.max assign="counter"}
{if %cat_num.first%}
{if $tmp} [img]{if $current_category.icon_url}{$current_category.icon_url}{else}{$xcart_web_dir}/icon.php?categoryid={$cat}{/if}[/img] {/if}
<table border=0 width="100%" cellspacing=5><tr>
{/if}
<td width="50%">{ $subcategories[cat_num].category_name|escape }
</td>
</tr><tr>
{ if %cat_num.last% }
</tr></table>
{/if}
{/section}

</TD></TR></TABLE>


Updated, works properly now, I just used two section loops and set the stpes at 2 and 1 so I could create columns and get rid of the is div by 2 that wasn't doing what I needed.

hth. ;)

SMDStudios 04-16-2004 01:48 PM

THANKS BOOMER!

I don't know what us newbies would do without you pros! :)

xdam 04-22-2004 10:29 AM

sorry i'm new to x-cart, on which page do i insert this code?

B00MER 04-22-2004 10:30 AM

customer/main/subcategories.tpl :wink:

BHMedia 04-23-2004 07:07 PM

Hey Boomer - I tried it out - It does display the sub categories but when i click on one of them it just goes blank? Any ideas. 3.5.7... I restored the file and everything works fine? werid


All times are GMT -8. The time now is 06:37 PM.

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